diff --git a/.gitignore b/.gitignore index 3cdf4d79f..3f8b414be 100644 --- a/.gitignore +++ b/.gitignore @@ -355,3 +355,4 @@ MigrationBackup/ # WinMerge bak files *.bak /switcher.json +/.claude/settings.local.json diff --git a/CLAUDE.md b/CLAUDE.md index bd514d8ac..810726b27 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -31,6 +31,11 @@ Test framework: **NUnit**. Test classes use `[TestFixture]` and `[Test]` attribu ## Architecture +### Code Generation + +- favour duplicated code in codegeneration to have staticaly defined methods that provide performance over reflection based code. +- code generation is done by processing the UML model and creating handlebars templates + ### Code Generation Pipeline Most code in this repo is **auto-generated** — files marked `THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!` must not be edited directly. @@ -104,3 +109,8 @@ Auto-generated DTOs use structured namespaces reflecting the KerML/SysML package - CI: GitHub Actions (`CodeQuality.yml`) — builds, tests, and runs SonarQube analysis - License: Apache 2.0 (code), LGPL v3.0 (metamodel files) - To add a new metaclass: update the UML XMI source files, then run the code generators — do not manually create AutoGen files + +## Quality rules + +- Prefer comparing 'Count' to 0 rather than using 'Any()', both for clarity and for performance +- Use 'StringBuilder.Append(char)' instead of 'StringBuilder.Append(string)' when the input is a constant unit string diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenEnumProvider/TransitionFeatureKindProvider.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenEnumProvider/TransitionFeatureKindProvider.cs index f5ffa038f..218d1be57 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenEnumProvider/TransitionFeatureKindProvider.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenEnumProvider/TransitionFeatureKindProvider.cs @@ -73,6 +73,48 @@ public static TransitionFeatureKind Parse(ReadOnlySpan value) throw new ArgumentException($"'{new string(value)}' is not a valid TransitionFeatureKind", nameof(value)); } + /// + /// Tries to parse the to a + /// + /// + /// The that is to be parsed + /// + /// + /// When this method returns, contains the value equivalent + /// to the span, if the conversion succeeded, or default if the conversion failed. + /// + /// + /// true if was converted successfully; otherwise, false. + /// + /// + /// This method is suited for string parsing + /// There are zero allocations, no boxing, Fast short-circuit evaluation + /// JIT friendly + /// + public static bool TryParse(ReadOnlySpan value, out TransitionFeatureKind result) + { + if (value.Length == 7 && value.Equals("trigger".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = TransitionFeatureKind.Trigger; + return true; + } + + if (value.Length == 5 && value.Equals("guard".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = TransitionFeatureKind.Guard; + return true; + } + + if (value.Length == 6 && value.Equals("effect".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = TransitionFeatureKind.Effect; + return true; + } + + result = default; + return false; + } + /// /// Parses the to a /// diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenEnumProvider/VisibilityKindProvider.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenEnumProvider/VisibilityKindProvider.cs index 9868846be..82ee5af4b 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenEnumProvider/VisibilityKindProvider.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenEnumProvider/VisibilityKindProvider.cs @@ -73,6 +73,48 @@ public static VisibilityKind Parse(ReadOnlySpan value) throw new ArgumentException($"'{new string(value)}' is not a valid VisibilityKind", nameof(value)); } + /// + /// Tries to parse the to a + /// + /// + /// The that is to be parsed + /// + /// + /// When this method returns, contains the value equivalent + /// to the span, if the conversion succeeded, or default if the conversion failed. + /// + /// + /// true if was converted successfully; otherwise, false. + /// + /// + /// This method is suited for string parsing + /// There are zero allocations, no boxing, Fast short-circuit evaluation + /// JIT friendly + /// + public static bool TryParse(ReadOnlySpan value, out VisibilityKind result) + { + if (value.Length == 7 && value.Equals("private".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = VisibilityKind.Private; + return true; + } + + if (value.Length == 9 && value.Equals("protected".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = VisibilityKind.Protected; + return true; + } + + if (value.Length == 6 && value.Equals("public".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = VisibilityKind.Public; + return true; + } + + result = default; + return false; + } + /// /// Parses the to a /// diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/AnnotatingElementReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/AnnotatingElementReader.cs index c61ad6030..1c93a4bfd 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/AnnotatingElementReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/AnnotatingElementReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; @@ -61,7 +62,8 @@ public class AnnotatingElementReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public AnnotatingElementReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public AnnotatingElementReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -107,6 +109,8 @@ public override IAnnotatingElement Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AnnotatingElement", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -160,6 +164,10 @@ public override IAnnotatingElement Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -176,6 +184,10 @@ public override IAnnotatingElement Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -238,7 +250,14 @@ public override IAnnotatingElement Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -252,12 +271,18 @@ public override IAnnotatingElement Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -273,12 +298,18 @@ public override IAnnotatingElement Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -286,6 +317,10 @@ public override IAnnotatingElement Read(XmlReader xmiReader, Uri currentLocation break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AnnotatingElement at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -335,6 +370,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AnnotatingElement", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -388,6 +425,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -404,6 +445,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -466,7 +511,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -480,12 +532,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -501,12 +559,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -514,6 +578,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AnnotatingElement at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/AssociationReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/AssociationReader.cs index 8216d7169..700d1b020 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/AssociationReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/AssociationReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -65,7 +66,8 @@ public class AssociationReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public AssociationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public AssociationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +113,8 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Association", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -194,6 +198,10 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -214,6 +222,10 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -230,6 +242,10 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -240,6 +256,10 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -302,7 +322,14 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -314,7 +341,14 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -326,7 +360,14 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -338,7 +379,14 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -352,12 +400,18 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -373,12 +427,18 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -394,12 +454,18 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -415,12 +481,18 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -428,6 +500,10 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Association at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -477,6 +553,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Association", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -560,6 +638,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -580,6 +662,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -596,6 +682,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -606,6 +696,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -668,7 +762,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -680,7 +781,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -692,7 +800,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -704,7 +819,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -718,12 +840,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -739,12 +867,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -760,12 +894,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -781,12 +921,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -794,6 +940,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Association at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/DependencyReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/DependencyReader.cs index 1264907be..cd8e94dc0 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/DependencyReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/DependencyReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; @@ -62,7 +63,8 @@ public class DependencyReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public DependencyReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public DependencyReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +110,8 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Dependency", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -130,6 +134,10 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { clientXmlAttributeReferences.Add(clientXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'client' on element {ElementId}", clientXmlAttributeValue, poco.Id); + } } if (clientXmlAttributeReferences.Count != 0) @@ -191,6 +199,10 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -211,6 +223,10 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -227,6 +243,10 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -237,6 +257,10 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var supplierXmlAttribute = xmiReader.GetAttribute("supplier"); @@ -251,6 +275,10 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { supplierXmlAttributeReferences.Add(supplierXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'supplier' on element {ElementId}", supplierXmlAttributeValue, poco.Id); + } } if (supplierXmlAttributeReferences.Count != 0) @@ -285,12 +313,18 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var clientId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "client", clientId); + if (Guid.TryParse(hrefSplit[1], out var clientId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "client", clientId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'client' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var clientValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var clientValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Client.Add(clientValue); } @@ -340,7 +374,14 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -352,7 +393,14 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -366,12 +414,18 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -387,12 +441,18 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -408,12 +468,18 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -429,12 +495,18 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -450,12 +522,18 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var supplierId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "supplier", supplierId); + if (Guid.TryParse(hrefSplit[1], out var supplierId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "supplier", supplierId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'supplier' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var supplierValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var supplierValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Supplier.Add(supplierValue); } @@ -463,6 +541,10 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Dependency at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -512,6 +594,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Dependency", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -534,6 +618,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { clientXmlAttributeReferences.Add(clientXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'client' on element {ElementId}", clientXmlAttributeValue, poco.Id); + } } if (clientXmlAttributeReferences.Count != 0) @@ -595,6 +683,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -615,6 +707,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -631,6 +727,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -641,6 +741,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var supplierXmlAttribute = xmiReader.GetAttribute("supplier"); @@ -655,6 +759,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { supplierXmlAttributeReferences.Add(supplierXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'supplier' on element {ElementId}", supplierXmlAttributeValue, poco.Id); + } } if (supplierXmlAttributeReferences.Count != 0) @@ -689,12 +797,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var clientId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "client", clientId); + if (Guid.TryParse(hrefSplit[1], out var clientId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "client", clientId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'client' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var clientValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var clientValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Client.Add(clientValue); } @@ -744,7 +858,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -756,7 +877,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -770,12 +898,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -791,12 +925,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -812,12 +952,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -833,12 +979,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -854,12 +1006,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var supplierId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "supplier", supplierId); + if (Guid.TryParse(hrefSplit[1], out var supplierId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "supplier", supplierId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'supplier' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var supplierValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var supplierValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Supplier.Add(supplierValue); } @@ -867,6 +1025,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Dependency at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/EnumerationDefinitionReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/EnumerationDefinitionReader.cs index 32b744c87..2cc664a97 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/EnumerationDefinitionReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/EnumerationDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -86,7 +87,8 @@ public class EnumerationDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public EnumerationDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public EnumerationDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -132,6 +134,8 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "EnumerationDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -215,6 +219,10 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -231,6 +239,10 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -293,7 +305,14 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -305,7 +324,14 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -317,7 +343,14 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -329,7 +362,14 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -343,12 +383,18 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -364,12 +410,18 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -377,6 +429,10 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading EnumerationDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -426,6 +482,8 @@ public override async Task ReadAsync(XmlReader xmiReader this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "EnumerationDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -509,6 +567,10 @@ public override async Task ReadAsync(XmlReader xmiReader { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -525,6 +587,10 @@ public override async Task ReadAsync(XmlReader xmiReader { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -587,7 +653,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -599,7 +672,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -611,7 +691,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -623,7 +710,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -637,12 +731,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -658,12 +758,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -671,6 +777,10 @@ public override async Task ReadAsync(XmlReader xmiReader break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading EnumerationDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FeatureReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FeatureReader.cs index 420b09617..f655dbbe5 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FeatureReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FeatureReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; @@ -64,7 +65,8 @@ public class FeatureReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public FeatureReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FeatureReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -110,6 +112,8 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Feature", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -138,7 +142,7 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -273,6 +277,10 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -289,6 +297,10 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -339,7 +351,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -363,7 +382,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -375,7 +401,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -387,7 +420,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -399,7 +439,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -411,7 +458,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -423,7 +477,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -435,7 +496,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -447,7 +515,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -459,7 +534,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -471,7 +553,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -483,7 +572,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -497,12 +593,18 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -518,12 +620,18 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -531,6 +639,10 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Feature at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -580,6 +692,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Feature", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -608,7 +722,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -743,6 +857,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -759,6 +877,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -809,7 +931,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -833,7 +962,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -845,7 +981,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -857,7 +1000,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -869,7 +1019,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -881,7 +1038,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -893,7 +1057,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -905,7 +1076,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -917,7 +1095,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -929,7 +1114,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -941,7 +1133,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -953,7 +1152,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -967,12 +1173,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -988,12 +1200,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1001,6 +1219,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Feature at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FeatureTypingReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FeatureTypingReader.cs index 98c1a7336..bd8457d6a 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FeatureTypingReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FeatureTypingReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; @@ -63,7 +64,8 @@ public class FeatureTypingReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public FeatureTypingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FeatureTypingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -109,6 +111,8 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureTyping", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -172,6 +176,10 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -192,6 +200,10 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -208,6 +220,10 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -218,6 +234,10 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var typeXmlAttribute = xmiReader.GetAttribute("type"); @@ -228,6 +248,10 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "type", typeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'type' on element {ElementId}", typeXmlAttribute, poco.Id); + } } var typedFeatureXmlAttribute = xmiReader.GetAttribute("typedFeature"); @@ -238,6 +262,10 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'typedFeature' on element {ElementId}", typedFeatureXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -300,7 +328,14 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -312,7 +347,14 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -326,12 +368,18 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -347,12 +395,18 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -368,12 +422,18 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -389,12 +449,18 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -410,12 +476,18 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var typeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "type", typeId); + if (Guid.TryParse(hrefSplit[1], out var typeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "type", typeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'type' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var typeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var typeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Type = typeValue; } @@ -431,12 +503,18 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var typedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var typedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'typedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var typedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var typedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.TypedFeature = typedFeatureValue; } @@ -444,6 +522,10 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureTyping at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -493,6 +575,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureTyping", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -556,6 +640,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -576,6 +664,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -592,6 +684,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -602,6 +698,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var typeXmlAttribute = xmiReader.GetAttribute("type"); @@ -612,6 +712,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "type", typeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'type' on element {ElementId}", typeXmlAttribute, poco.Id); + } } var typedFeatureXmlAttribute = xmiReader.GetAttribute("typedFeature"); @@ -622,6 +726,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'typedFeature' on element {ElementId}", typedFeatureXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -684,7 +792,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -696,7 +811,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -710,12 +832,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -731,12 +859,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -752,12 +886,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -773,12 +913,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -794,12 +940,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var typeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "type", typeId); + if (Guid.TryParse(hrefSplit[1], out var typeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "type", typeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'type' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var typeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var typeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Type = typeValue; } @@ -815,12 +967,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var typedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var typedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'typedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var typedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var typedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.TypedFeature = typedFeatureValue; } @@ -828,6 +986,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureTyping at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FlowReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FlowReader.cs index f0c0083bc..3ce2915c5 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FlowReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FlowReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; @@ -69,7 +70,8 @@ public class FlowReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public FlowReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FlowReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -115,6 +117,8 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Flow", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -143,7 +147,7 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -288,6 +292,10 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -308,6 +316,10 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -324,6 +336,10 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -334,6 +350,10 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -384,7 +404,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -408,7 +435,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -420,7 +454,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -432,7 +473,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -444,7 +492,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -456,7 +511,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -468,7 +530,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -480,7 +549,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -492,7 +568,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -504,7 +587,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -516,7 +606,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -528,7 +625,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -540,7 +644,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -554,12 +665,18 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -575,12 +692,18 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -596,12 +719,18 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -617,12 +746,18 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -630,6 +765,10 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Flow at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -679,6 +818,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Flow", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -707,7 +848,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -852,6 +993,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -872,6 +1017,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -888,6 +1037,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -898,6 +1051,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -948,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -972,7 +1136,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -984,7 +1155,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -996,7 +1174,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -1008,7 +1193,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1020,7 +1212,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1032,7 +1231,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -1044,7 +1250,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1056,7 +1269,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1068,7 +1288,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1080,7 +1307,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1092,7 +1326,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1104,7 +1345,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1118,12 +1366,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -1139,12 +1393,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1160,12 +1420,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -1181,12 +1447,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1194,6 +1466,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Flow at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FramedConcernMembershipReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FramedConcernMembershipReader.cs index aec6ea208..56e3ac930 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FramedConcernMembershipReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/FramedConcernMembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.Systems.Requirements; using SysML2.NET.Core.POCO.Core.Features; @@ -67,7 +68,8 @@ public class FramedConcernMembershipReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public FramedConcernMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FramedConcernMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -113,6 +115,8 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FramedConcernMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -168,7 +172,7 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(kindXmlAttribute)) { - if (Enum.TryParse(kindXmlAttribute, true, out RequirementConstraintKind kindXmlAttributeAsEnum)) + if (RequirementConstraintKindProvider.TryParse(kindXmlAttribute.AsSpan(), out var kindXmlAttributeAsEnum)) { poco.Kind = kindXmlAttributeAsEnum; } @@ -186,6 +190,10 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -206,6 +214,10 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -222,6 +234,10 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -232,13 +248,17 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -304,7 +324,14 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -316,7 +343,14 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -328,7 +362,14 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(kindValue)) { - poco.Kind = (RequirementConstraintKind)Enum.Parse(typeof(RequirementConstraintKind), kindValue, true); + if (RequirementConstraintKindProvider.TryParse(kindValue.AsSpan(), out var kindValueAsEnum)) + { + poco.Kind = kindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'kind' on element {ElementId}", kindValue, poco.Id); + } } break; @@ -342,12 +383,18 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -363,12 +410,18 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -384,12 +437,18 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -405,12 +464,18 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -424,12 +489,23 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FramedConcernMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -479,6 +555,8 @@ public override async Task ReadAsync(XmlReader xmiRead this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FramedConcernMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -534,7 +612,7 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(kindXmlAttribute)) { - if (Enum.TryParse(kindXmlAttribute, true, out RequirementConstraintKind kindXmlAttributeAsEnum)) + if (RequirementConstraintKindProvider.TryParse(kindXmlAttribute.AsSpan(), out var kindXmlAttributeAsEnum)) { poco.Kind = kindXmlAttributeAsEnum; } @@ -552,6 +630,10 @@ public override async Task ReadAsync(XmlReader xmiRead { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -572,6 +654,10 @@ public override async Task ReadAsync(XmlReader xmiRead { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -588,6 +674,10 @@ public override async Task ReadAsync(XmlReader xmiRead { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -598,13 +688,17 @@ public override async Task ReadAsync(XmlReader xmiRead { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -670,7 +764,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -682,7 +783,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -694,7 +802,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(kindValue)) { - poco.Kind = (RequirementConstraintKind)Enum.Parse(typeof(RequirementConstraintKind), kindValue, true); + if (RequirementConstraintKindProvider.TryParse(kindValue.AsSpan(), out var kindValueAsEnum)) + { + poco.Kind = kindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'kind' on element {ElementId}", kindValue, poco.Id); + } } break; @@ -708,12 +823,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -729,12 +850,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -750,12 +877,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -771,12 +904,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -790,12 +929,23 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FramedConcernMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/LiteralIntegerReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/LiteralIntegerReader.cs index ee51eea31..e97980cde 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/LiteralIntegerReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/LiteralIntegerReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -67,7 +68,8 @@ public class LiteralIntegerReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public LiteralIntegerReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public LiteralIntegerReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -113,6 +115,8 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralInteger", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -141,7 +145,7 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -276,6 +280,10 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -292,6 +300,10 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var valueXmlAttribute = xmiReader.GetAttribute("value"); @@ -352,7 +364,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -376,7 +395,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -388,7 +414,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -400,7 +433,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -412,7 +452,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -424,7 +471,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -436,7 +490,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -448,7 +509,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -460,7 +528,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -472,7 +547,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -484,7 +566,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -496,7 +585,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -510,12 +606,18 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -531,12 +633,18 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -550,12 +658,23 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(valueValue)) { - poco.Value = int.Parse(valueValue); + if (int.TryParse(valueValue, out var valueValueAsInt)) + { + poco.Value = valueValueAsInt; + } + else + { + this.logger.LogWarning("Failed to parse int value '{Value}' for property 'value' on element {ElementId}", valueValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralInteger at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -605,6 +724,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralInteger", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -633,7 +754,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -768,6 +889,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -784,6 +909,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var valueXmlAttribute = xmiReader.GetAttribute("value"); @@ -844,7 +973,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -868,7 +1004,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -880,7 +1023,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -892,7 +1042,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -904,7 +1061,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -916,7 +1080,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -928,7 +1099,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -940,7 +1118,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -952,7 +1137,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -964,7 +1156,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -976,7 +1175,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -988,7 +1194,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1002,12 +1215,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1023,12 +1242,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1042,12 +1267,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(valueValue)) { - poco.Value = int.Parse(valueValue); + if (int.TryParse(valueValue, out var valueValueAsInt)) + { + poco.Value = valueValueAsInt; + } + else + { + this.logger.LogWarning("Failed to parse int value '{Value}' for property 'value' on element {ElementId}", valueValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralInteger at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/LiteralRationalReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/LiteralRationalReader.cs index de420df3a..b08510e1f 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/LiteralRationalReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/LiteralRationalReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -67,7 +68,8 @@ public class LiteralRationalReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public LiteralRationalReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public LiteralRationalReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -113,6 +115,8 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralRational", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -141,7 +145,7 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -276,6 +280,10 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -292,6 +300,10 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var valueXmlAttribute = xmiReader.GetAttribute("value"); @@ -352,7 +364,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -376,7 +395,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -388,7 +414,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -400,7 +433,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -412,7 +452,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -424,7 +471,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -436,7 +490,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -448,7 +509,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -460,7 +528,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -472,7 +547,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -484,7 +566,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -496,7 +585,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -510,12 +606,18 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -531,12 +633,18 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -550,12 +658,23 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(valueValue)) { - poco.Value = double.Parse(valueValue); + if (double.TryParse(valueValue, out var valueValueAsDouble)) + { + poco.Value = valueValueAsDouble; + } + else + { + this.logger.LogWarning("Failed to parse double value '{Value}' for property 'value' on element {ElementId}", valueValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralRational at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -605,6 +724,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralRational", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -633,7 +754,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -768,6 +889,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -784,6 +909,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var valueXmlAttribute = xmiReader.GetAttribute("value"); @@ -844,7 +973,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -868,7 +1004,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -880,7 +1023,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -892,7 +1042,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -904,7 +1061,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -916,7 +1080,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -928,7 +1099,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -940,7 +1118,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -952,7 +1137,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -964,7 +1156,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -976,7 +1175,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -988,7 +1194,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1002,12 +1215,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1023,12 +1242,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1042,12 +1267,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(valueValue)) { - poco.Value = double.Parse(valueValue); + if (double.TryParse(valueValue, out var valueValueAsDouble)) + { + poco.Value = valueValueAsDouble; + } + else + { + this.logger.LogWarning("Failed to parse double value '{Value}' for property 'value' on element {ElementId}", valueValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralRational at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/MembershipReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/MembershipReader.cs index 5a78c2a75..ea4c13313 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/MembershipReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/MembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; @@ -62,7 +63,8 @@ public class MembershipReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public MembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public MembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +110,8 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Membership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -167,6 +171,10 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "memberElement", memberElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'memberElement' on element {ElementId}", memberElementXmlAttribute, poco.Id); + } } var memberNameXmlAttribute = xmiReader.GetAttribute("memberName"); @@ -195,6 +203,10 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -215,6 +227,10 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -231,6 +247,10 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -241,13 +261,17 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -313,7 +337,14 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -325,7 +356,14 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -339,12 +377,18 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var memberElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "memberElement", memberElementId); + if (Guid.TryParse(hrefSplit[1], out var memberElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "memberElement", memberElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'memberElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var memberElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var memberElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.MemberElement = memberElementValue; } @@ -384,12 +428,18 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -405,12 +455,18 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -426,12 +482,18 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -447,12 +509,18 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -466,12 +534,23 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Membership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -521,6 +600,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Membership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -580,6 +661,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "memberElement", memberElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'memberElement' on element {ElementId}", memberElementXmlAttribute, poco.Id); + } } var memberNameXmlAttribute = xmiReader.GetAttribute("memberName"); @@ -608,6 +693,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -628,6 +717,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -644,6 +737,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -654,13 +751,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -726,7 +827,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -738,7 +846,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -752,12 +867,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var memberElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "memberElement", memberElementId); + if (Guid.TryParse(hrefSplit[1], out var memberElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "memberElement", memberElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'memberElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var memberElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var memberElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.MemberElement = memberElementValue; } @@ -797,12 +918,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -818,12 +945,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -839,12 +972,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -860,12 +999,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -879,12 +1024,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Membership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/MultiplicityRangeReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/MultiplicityRangeReader.cs index 240d7cb9b..7e51476b2 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/MultiplicityRangeReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/MultiplicityRangeReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -66,7 +67,8 @@ public class MultiplicityRangeReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public MultiplicityRangeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public MultiplicityRangeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +114,8 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MultiplicityRange", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +144,7 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -275,6 +279,10 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -291,6 +299,10 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -341,7 +353,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -365,7 +384,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -377,7 +403,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -389,7 +422,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -401,7 +441,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -413,7 +460,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -425,7 +479,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -437,7 +498,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -449,7 +517,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -461,7 +536,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -473,7 +555,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -485,7 +574,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -499,12 +595,18 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -520,12 +622,18 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -533,6 +641,10 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MultiplicityRange at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -582,6 +694,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MultiplicityRange", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -610,7 +724,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -745,6 +859,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -761,6 +879,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -811,7 +933,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -835,7 +964,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -847,7 +983,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -859,7 +1002,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -871,7 +1021,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -883,7 +1040,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -895,7 +1059,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -907,7 +1078,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -919,7 +1097,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -931,7 +1116,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -943,7 +1135,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -955,7 +1154,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -969,12 +1175,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -990,12 +1202,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1003,6 +1221,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MultiplicityRange at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/OwningMembershipReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/OwningMembershipReader.cs index 43aa08144..b78e51826 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/OwningMembershipReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/OwningMembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; @@ -62,7 +63,8 @@ public class OwningMembershipReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public OwningMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public OwningMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +110,8 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "OwningMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -171,6 +175,10 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -191,6 +199,10 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -207,6 +219,10 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -217,13 +233,17 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -289,7 +309,14 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -301,7 +328,14 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -315,12 +349,18 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -336,12 +376,18 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -357,12 +403,18 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -378,12 +430,18 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -397,12 +455,23 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading OwningMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -452,6 +521,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "OwningMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -515,6 +586,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -535,6 +610,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -551,6 +630,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -561,13 +644,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -633,7 +720,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -645,7 +739,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -659,12 +760,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -680,12 +787,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -701,12 +814,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -722,12 +841,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -741,12 +866,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading OwningMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/ReferenceSubsettingReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/ReferenceSubsettingReader.cs index 1dac13566..8d10b222d 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/ReferenceSubsettingReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/ReferenceSubsettingReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; @@ -63,7 +64,8 @@ public class ReferenceSubsettingReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ReferenceSubsettingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ReferenceSubsettingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -109,6 +111,8 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ReferenceSubsetting", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -172,6 +176,10 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -192,6 +200,10 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -208,6 +220,10 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -218,6 +234,10 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var referencedFeatureXmlAttribute = xmiReader.GetAttribute("referencedFeature"); @@ -228,6 +248,10 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "referencedFeature", referencedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'referencedFeature' on element {ElementId}", referencedFeatureXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -290,7 +314,14 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -302,7 +333,14 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -316,12 +354,18 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -337,12 +381,18 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -358,12 +408,18 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -379,12 +435,18 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -400,12 +462,18 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var referencedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "referencedFeature", referencedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var referencedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "referencedFeature", referencedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'referencedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var referencedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var referencedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ReferencedFeature = referencedFeatureValue; } @@ -413,6 +481,10 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ReferenceSubsetting at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -462,6 +534,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ReferenceSubsetting", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -525,6 +599,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -545,6 +623,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -561,6 +643,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -571,6 +657,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var referencedFeatureXmlAttribute = xmiReader.GetAttribute("referencedFeature"); @@ -581,6 +671,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "referencedFeature", referencedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'referencedFeature' on element {ElementId}", referencedFeatureXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -643,7 +737,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -655,7 +756,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -669,12 +777,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -690,12 +804,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -711,12 +831,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -732,12 +858,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -753,12 +885,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var referencedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "referencedFeature", referencedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var referencedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "referencedFeature", referencedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'referencedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var referencedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var referencedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ReferencedFeature = referencedFeatureValue; } @@ -766,6 +904,10 @@ public override async Task ReadAsync(XmlReader xmiReader, break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ReferenceSubsetting at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/RequirementUsageReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/RequirementUsageReader.cs index c0014714f..1c8e6f491 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/RequirementUsageReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/RequirementUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -91,7 +92,8 @@ public class RequirementUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public RequirementUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public RequirementUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -137,6 +139,8 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "RequirementUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -158,7 +162,7 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -303,6 +307,10 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -319,13 +327,17 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -374,7 +386,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -398,7 +417,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -410,7 +436,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -422,7 +455,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -434,7 +474,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -446,7 +493,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -458,7 +512,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -470,7 +531,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -482,7 +550,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -494,7 +569,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -506,7 +588,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -518,7 +607,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -530,7 +626,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -544,12 +647,18 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -565,12 +674,18 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -584,7 +699,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; @@ -602,6 +724,10 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading RequirementUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -651,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "RequirementUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -672,7 +800,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -817,6 +945,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -833,13 +965,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -888,7 +1024,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -912,7 +1055,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -924,7 +1074,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -936,7 +1093,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -948,7 +1112,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -960,7 +1131,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -972,7 +1150,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -984,7 +1169,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -996,7 +1188,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1008,7 +1207,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1020,7 +1226,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1032,7 +1245,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1044,7 +1264,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1058,12 +1285,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1079,12 +1312,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1098,7 +1337,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; @@ -1116,6 +1362,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading RequirementUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/SelectExpressionReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/SelectExpressionReader.cs index 772f007e1..5368ea304 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/SelectExpressionReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/SelectExpressionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -67,7 +68,8 @@ public class SelectExpressionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public SelectExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public SelectExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -113,6 +115,8 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SelectExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -141,7 +145,7 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -283,6 +287,10 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -299,6 +307,10 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -349,7 +361,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -373,7 +392,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -385,7 +411,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -397,7 +430,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -409,7 +449,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -421,7 +468,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -433,7 +487,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -445,7 +506,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -457,7 +525,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -469,7 +544,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -481,7 +563,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -493,7 +582,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -519,12 +615,18 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -540,12 +642,18 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -553,6 +661,10 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SelectExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -602,6 +714,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SelectExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -630,7 +744,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -772,6 +886,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -788,6 +906,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -838,7 +960,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -862,7 +991,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -874,7 +1010,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -886,7 +1029,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -898,7 +1048,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -910,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -922,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -934,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -946,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -958,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -970,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -982,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1008,12 +1214,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1029,12 +1241,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1042,6 +1260,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SelectExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/SubclassificationReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/SubclassificationReader.cs index f33076269..441c66d7b 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/SubclassificationReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/SubclassificationReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; @@ -63,7 +64,8 @@ public class SubclassificationReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public SubclassificationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public SubclassificationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -109,6 +111,8 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Subclassification", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -172,6 +176,10 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -192,6 +200,10 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -208,6 +220,10 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -218,6 +234,10 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var subclassifierXmlAttribute = xmiReader.GetAttribute("subclassifier"); @@ -228,6 +248,10 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subclassifier", subclassifierXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'subclassifier' on element {ElementId}", subclassifierXmlAttribute, poco.Id); + } } var superclassifierXmlAttribute = xmiReader.GetAttribute("superclassifier"); @@ -238,6 +262,10 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "superclassifier", superclassifierXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'superclassifier' on element {ElementId}", superclassifierXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -300,7 +328,14 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -312,7 +347,14 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -326,12 +368,18 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -347,12 +395,18 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -368,12 +422,18 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -389,12 +449,18 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -410,12 +476,18 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var subclassifierId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subclassifier", subclassifierId); + if (Guid.TryParse(hrefSplit[1], out var subclassifierId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subclassifier", subclassifierId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'subclassifier' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var subclassifierValue = (IClassifier)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var subclassifierValue = (IClassifier)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Subclassifier = subclassifierValue; } @@ -431,12 +503,18 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var superclassifierId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "superclassifier", superclassifierId); + if (Guid.TryParse(hrefSplit[1], out var superclassifierId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "superclassifier", superclassifierId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'superclassifier' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var superclassifierValue = (IClassifier)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var superclassifierValue = (IClassifier)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Superclassifier = superclassifierValue; } @@ -444,6 +522,10 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Subclassification at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -493,6 +575,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Subclassification", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -556,6 +640,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -576,6 +664,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -592,6 +684,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -602,6 +698,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var subclassifierXmlAttribute = xmiReader.GetAttribute("subclassifier"); @@ -612,6 +712,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subclassifier", subclassifierXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'subclassifier' on element {ElementId}", subclassifierXmlAttribute, poco.Id); + } } var superclassifierXmlAttribute = xmiReader.GetAttribute("superclassifier"); @@ -622,6 +726,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "superclassifier", superclassifierXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'superclassifier' on element {ElementId}", superclassifierXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -684,7 +792,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -696,7 +811,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -710,12 +832,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -731,12 +859,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -752,12 +886,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -773,12 +913,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -794,12 +940,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var subclassifierId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subclassifier", subclassifierId); + if (Guid.TryParse(hrefSplit[1], out var subclassifierId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subclassifier", subclassifierId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'subclassifier' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var subclassifierValue = (IClassifier)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var subclassifierValue = (IClassifier)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Subclassifier = subclassifierValue; } @@ -815,12 +967,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var superclassifierId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "superclassifier", superclassifierId); + if (Guid.TryParse(hrefSplit[1], out var superclassifierId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "superclassifier", superclassifierId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'superclassifier' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var superclassifierValue = (IClassifier)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var superclassifierValue = (IClassifier)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Superclassifier = superclassifierValue; } @@ -828,6 +986,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Subclassification at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/TextualRepresentationReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/TextualRepresentationReader.cs index c9a2ddab9..7e84e4777 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/TextualRepresentationReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/TextualRepresentationReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; @@ -61,7 +62,8 @@ public class TextualRepresentationReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public TextualRepresentationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public TextualRepresentationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -107,6 +109,8 @@ public override ITextualRepresentation Read(XmlReader xmiReader, Uri currentLoca this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "TextualRepresentation", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -174,6 +178,10 @@ public override ITextualRepresentation Read(XmlReader xmiReader, Uri currentLoca { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -190,6 +198,10 @@ public override ITextualRepresentation Read(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -264,7 +276,14 @@ public override ITextualRepresentation Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -290,12 +309,18 @@ public override ITextualRepresentation Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -311,12 +336,18 @@ public override ITextualRepresentation Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -324,6 +355,10 @@ public override ITextualRepresentation Read(XmlReader xmiReader, Uri currentLoca break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading TextualRepresentation at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -373,6 +408,8 @@ public override async Task ReadAsync(XmlReader xmiReader this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "TextualRepresentation", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -440,6 +477,10 @@ public override async Task ReadAsync(XmlReader xmiReader { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -456,6 +497,10 @@ public override async Task ReadAsync(XmlReader xmiReader { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -530,7 +575,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -556,12 +608,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -577,12 +635,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -590,6 +654,10 @@ public override async Task ReadAsync(XmlReader xmiReader break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading TextualRepresentation at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/UsageReader.cs b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/UsageReader.cs index a91ef454f..c5d989531 100644 --- a/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/UsageReader.cs +++ b/SysML2.NET.CodeGenerator.Tests/Expected/UML/Core/AutoGenReaders/UsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; @@ -87,7 +88,8 @@ public class UsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public UsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public UsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -133,6 +135,8 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Usage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -161,7 +165,7 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -296,6 +300,10 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -312,6 +320,10 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -362,7 +374,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -386,7 +405,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -398,7 +424,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -410,7 +443,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -422,7 +462,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -434,7 +481,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -446,7 +500,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -458,7 +519,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -470,7 +538,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -482,7 +557,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -494,7 +576,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -506,7 +595,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -520,12 +616,18 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -541,12 +643,18 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -554,6 +662,10 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Usage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -603,6 +715,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Usage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -631,7 +745,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -766,6 +880,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -782,6 +900,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -832,7 +954,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -856,7 +985,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -868,7 +1004,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -880,7 +1023,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -892,7 +1042,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -904,7 +1061,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -916,7 +1080,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -928,7 +1099,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -940,7 +1118,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -952,7 +1137,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -964,7 +1156,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -976,7 +1175,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -990,12 +1196,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1011,12 +1223,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1024,6 +1242,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Usage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator.Tests/Generators/UmlHandleBarsGenerators/UmlCoreXmiWriterGeneratorTestFixture.cs b/SysML2.NET.CodeGenerator.Tests/Generators/UmlHandleBarsGenerators/UmlCoreXmiWriterGeneratorTestFixture.cs new file mode 100644 index 000000000..cf6aaa900 --- /dev/null +++ b/SysML2.NET.CodeGenerator.Tests/Generators/UmlHandleBarsGenerators/UmlCoreXmiWriterGeneratorTestFixture.cs @@ -0,0 +1,53 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Tests.Generators.UmlHandleBarsGenerators +{ + using System.IO; + using System.Threading.Tasks; + + using NUnit.Framework; + + using SysML2.NET.CodeGenerator.Generators.UmlHandleBarsGenerators; + + [TestFixture] + public class UmlCoreXmiWriterGeneratorTestFixture + { + private DirectoryInfo umlXmiWriterDirectoryInfo; + private UmlCoreXmiWriterGenerator umlCoreXmiWriterGenerator; + + [OneTimeSetUp] + public void OneTimeSetup() + { + var directoryInfo = new DirectoryInfo(TestContext.CurrentContext.TestDirectory); + + var path = Path.Combine("UML", "_SysML2.NET.Serializer.Xmi.AutoGenWriters"); + + this.umlXmiWriterDirectoryInfo = directoryInfo.CreateSubdirectory(path); + this.umlCoreXmiWriterGenerator = new UmlCoreXmiWriterGenerator(); + } + + [Test] + public async Task VerifyXmiWritersAreGenerated() + { + await Assert.ThatAsync(() => this.umlCoreXmiWriterGenerator.GenerateAsync(GeneratorSetupFixture.XmiReaderResult, this.umlXmiWriterDirectoryInfo), Throws.Nothing); + } + } +} diff --git a/SysML2.NET.CodeGenerator.Tests/HandleBarHelpers/ClassHelperTestFixture.cs b/SysML2.NET.CodeGenerator.Tests/HandleBarHelpers/ClassHelperTestFixture.cs new file mode 100644 index 000000000..dd923b9b1 --- /dev/null +++ b/SysML2.NET.CodeGenerator.Tests/HandleBarHelpers/ClassHelperTestFixture.cs @@ -0,0 +1,228 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Tests.Generators.UmlHandleBarsGenerators +{ + using System; + using System.Collections.Generic; + using System.Linq; + + using HandlebarsDotNet; + using HandlebarsDotNet.Helpers; + + using NUnit.Framework; + + using SysML2.NET.CodeGenerator.Extensions; + using SysML2.NET.CodeGenerator.HandleBarHelpers; + + using uml4net.Extensions; + using uml4net.SimpleClassifiers; + using uml4net.StructuredClassifiers; + + [TestFixture] + public class ClassHelperTestFixture + { + private IHandlebars handlebars; + private List allClasses; + + [OneTimeSetUp] + public void OneTimeSetUp() + { + this.handlebars = Handlebars.CreateSharedEnvironment(); + HandlebarsHelpers.Register(this.handlebars); + this.handlebars.RegisterClassHelper(); + + this.allClasses = GeneratorSetupFixture.XmiReaderResult.QueryContainedAndImported("SysML") + .SelectMany(x => x.PackagedElement.OfType()) + .ToList(); + } + + /// + /// Helper to invoke a template with IClass as context via {{#each}} + /// + private string RenderWithClassContext(string helperExpression, IClass @class) + { + var template = this.handlebars.Compile($"{{{{#each items}}}}{helperExpression}{{{{/each}}}}"); + return template(new { items = new[] { @class } }); + } + + [Test] + public void Verify_that_WriteEnumerationNameSpaces_writes_using_statements_for_enum_properties() + { + var classWithEnums = this.allClasses.FirstOrDefault(c => + c.QueryAllProperties().Any(p => p.QueryIsEnum())); + + if (classWithEnums == null) + { + Assert.Ignore("No class with enum properties found in the test data"); + } + + var result = this.RenderWithClassContext("{{Class.WriteEnumerationNameSpaces}}", classWithEnums); + + Assert.That(result, Does.Contain("using SysML2.NET.Core.")); + } + + [Test] + public void Verify_that_WriteEnumerationNameSpaces_writes_nothing_for_class_without_enums() + { + var classWithoutEnums = this.allClasses.FirstOrDefault(c => + !c.QueryAllProperties().Any(p => p.QueryIsEnum())); + + if (classWithoutEnums == null) + { + Assert.Ignore("All classes have enum properties"); + } + + var result = this.RenderWithClassContext("{{Class.WriteEnumerationNameSpaces}}", classWithoutEnums); + + Assert.That(result, Is.Empty); + } + + [Test] + public void Verify_that_WriteEnumerationNameSpace_writes_using_for_enumeration() + { + var enumerations = GeneratorSetupFixture.XmiReaderResult.QueryContainedAndImported("SysML") + .SelectMany(x => x.PackagedElement.OfType()) + .ToList(); + + if (enumerations.Count == 0) + { + Assert.Ignore("No enumerations found in the test data"); + } + + var template = this.handlebars.Compile("{{#each items}}{{Class.WriteEnumerationNameSpace}}{{/each}}"); + var result = template(new { items = new[] { enumerations.First() } }); + + Assert.That(result, Does.Contain("using SysML2.NET.Core.")); + } + + [Test] + public void Verify_that_WriteNameSpaces_writes_using_statements_with_DTO_prefix() + { + var testClass = this.allClasses.First(c => c.SuperClass.Count > 0); + + var result = this.RenderWithClassContext("{{Class.WriteNameSpaces this \"DTO\"}}", testClass); + + Assert.That(result, Does.Contain("using SysML2.NET.Core.DTO.")); + } + + [Test] + public void Verify_that_WriteNameSpaces_writes_using_statements_with_POCO_prefix() + { + var testClass = this.allClasses.First(c => c.SuperClass.Count > 0); + + var result = this.RenderWithClassContext("{{Class.WriteNameSpaces this \"POCO\"}}", testClass); + + Assert.That(result, Does.Contain("using SysML2.NET.Core.POCO.")); + } + + [Test] + public void Verify_that_WriteCountAllNonDerivedProperties_writes_numeric_count() + { + var testClass = this.allClasses.First(c => !c.IsAbstract); + + var result = this.RenderWithClassContext("{{Class.WriteCountAllNonDerivedProperties}}", testClass); + + Assert.That(result, Is.Not.Null.And.Not.Empty); + Assert.That(int.TryParse(result.Trim(), out var count), Is.True, + $"Expected numeric output but got: '{result}'"); + Assert.That(count, Is.GreaterThanOrEqualTo(0)); + } + + [Test] + public void Verify_that_QueryAllNonDerivedNonRedefinedProperties_does_not_throw() + { + var testClass = this.allClasses.First(c => !c.IsAbstract && c.QueryAllNonDerivedNonRedefinedProperties().Count > 0); + + Assert.That(() => this.RenderWithClassContext( + "{{#Class.QueryAllNonDerivedNonRedefinedProperties}}item{{/Class.QueryAllNonDerivedNonRedefinedProperties}}", + testClass), Throws.Nothing); + } + + [Test] + public void Verify_that_QueryAllNonDerivedNonRedefinedProperties_returns_expected_count() + { + var testClass = this.allClasses.First(c => !c.IsAbstract); + + var expectedCount = testClass.QueryAllNonDerivedNonRedefinedProperties().Count; + var countResult = this.RenderWithClassContext("{{Class.WriteCountAllNonDerivedNonRedefinedProperties}}", testClass); + var actualCount = int.Parse(countResult.Trim()); + + Assert.That(actualCount, Is.EqualTo(expectedCount)); + } + + [Test] + public void Verify_that_WriteCountAllNonDerivedNonRedefinedProperties_writes_numeric_count() + { + var testClass = this.allClasses.First(c => !c.IsAbstract); + + var result = this.RenderWithClassContext("{{Class.WriteCountAllNonDerivedNonRedefinedProperties}}", testClass); + + Assert.That(result, Is.Not.Null.And.Not.Empty); + Assert.That(int.TryParse(result.Trim(), out var count), Is.True, + $"Expected numeric output but got: '{result}'"); + Assert.That(count, Is.GreaterThanOrEqualTo(0)); + } + + [Test] + public void Verify_that_WriteInternalInterface_does_not_throw() + { + var testClass = this.allClasses.First(c => !c.IsAbstract); + + var result = this.RenderWithClassContext("{{Class.WriteInternalInterface}}", testClass); + + Assert.That(result, Is.Not.Null); + } + + [Test] + public void Verify_that_QueryNonDerivedCompositeAggregation_iterates_composite_properties() + { + var testClass = this.allClasses.First(c => !c.IsAbstract); + + var result = this.RenderWithClassContext( + "{{#Class.QueryNonDerivedCompositeAggregation}}{{Name}},{{/Class.QueryNonDerivedCompositeAggregation}}", + testClass); + + Assert.That(result, Is.Not.Null); + } + + [Test] + public void Verify_that_QueryAllPropertiesSorted_does_not_throw() + { + var testClass = this.allClasses.First(c => c.QueryAllProperties().Count > 1); + + Assert.That(() => this.RenderWithClassContext( + "{{#Class.QueryAllPropertiesSorted}}item{{/Class.QueryAllPropertiesSorted}}", + testClass), Throws.Nothing); + } + + [Test] + public void Verify_that_all_helpers_can_be_invoked_on_every_class_without_throwing() + { + foreach (var @class in this.allClasses.Take(10)) + { + Assert.That(() => this.RenderWithClassContext( + "{{Class.WriteCountAllNonDerivedProperties}}|{{Class.WriteCountAllNonDerivedNonRedefinedProperties}}|{{Class.WriteInternalInterface}}", + @class), Throws.Nothing, + $"Failed for class {@class.Name}"); + } + } + } +} diff --git a/SysML2.NET.CodeGenerator.Tests/HandleBarHelpers/PropertyHelperTestFixture.cs b/SysML2.NET.CodeGenerator.Tests/HandleBarHelpers/PropertyHelperTestFixture.cs new file mode 100644 index 000000000..f457d5a64 --- /dev/null +++ b/SysML2.NET.CodeGenerator.Tests/HandleBarHelpers/PropertyHelperTestFixture.cs @@ -0,0 +1,472 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Tests.Generators.UmlHandleBarsGenerators +{ + using System.Collections.Generic; + using System.Linq; + + using HandlebarsDotNet; + using HandlebarsDotNet.Helpers; + + using NUnit.Framework; + + using SysML2.NET.CodeGenerator.Extensions; + using SysML2.NET.CodeGenerator.HandleBarHelpers; + + using uml4net.Classification; + using uml4net.Extensions; + using uml4net.StructuredClassifiers; + + [TestFixture] + public class PropertyHelperTestFixture + { + private IHandlebars handlebars; + private List allClasses; + private IClass testClass; + private IProperty testProperty; + private IProperty derivedProperty; + + [OneTimeSetUp] + public void OneTimeSetUp() + { + this.handlebars = Handlebars.CreateSharedEnvironment(); + HandlebarsHelpers.Register(this.handlebars); + PropertyHelper.RegisterPropertyHelper(this.handlebars); + + this.allClasses = GeneratorSetupFixture.XmiReaderResult.QueryContainedAndImported("SysML") + .SelectMany(x => x.PackagedElement.OfType()) + .ToList(); + + this.testClass = this.allClasses.First(x => !x.IsAbstract); + this.testProperty = this.testClass.QueryAllProperties().First(); + this.derivedProperty = this.allClasses + .SelectMany(c => c.QueryAllProperties()) + .First(p => p.IsDerived || p.IsDerivedUnion); + } + + /// + /// Renders a template with IProperty as context using {{#each}} to set context.Value properly + /// + private string RenderWithPropertyContext(string helperExpression, IProperty property) + { + var template = this.handlebars.Compile($"{{{{#each items}}}}{helperExpression}{{{{/each}}}}"); + return template(new { items = new[] { property } }); + } + + /// + /// Renders a template with IProperty as context and an IClass in parent scope + /// + private string RenderWithPropertyAndClassContext(string helperExpression, IProperty property, IClass @class) + { + var template = this.handlebars.Compile($"{{{{#each items}}}}{helperExpression}{{{{/each}}}}"); + return template(new { items = new[] { property }, classObj = @class }); + } + + // ------------------------------------------------------------------- + // Property.WriteForDTOInterface (context.Value = IProperty) + // ------------------------------------------------------------------- + + [Test] + public void Verify_that_WriteForDTOInterface_generates_property_declaration() + { + var result = this.RenderWithPropertyContext("{{Property.WriteForDTOInterface}}", this.testProperty); + + Assert.That(result.Trim(), Is.Not.Empty); + Assert.That(result, Does.Contain("get")); + } + + [Test] + public void Verify_that_WriteForDTOInterface_generates_for_multiple_property_types() + { + var properties = this.allClasses + .SelectMany(c => c.QueryAllProperties()) + .Take(20); + + foreach (var property in properties) + { + var result = this.RenderWithPropertyContext("{{Property.WriteForDTOInterface}}", property); + + Assert.That(result.Trim(), Is.Not.Empty, + $"WriteForDTOInterface produced empty output for property {property.Name}"); + } + } + + // ------------------------------------------------------------------- + // Property.WriteForPOCOInterface (context.Value = IProperty) + // ------------------------------------------------------------------- + + [Test] + public void Verify_that_WriteForPOCOInterface_generates_property_declaration() + { + var result = this.RenderWithPropertyContext("{{Property.WriteForPOCOInterface}}", this.testProperty); + + Assert.That(result.Trim(), Is.Not.Empty); + } + + [Test] + public void Verify_that_WriteForPOCOInterface_generates_for_multiple_property_types() + { + var properties = this.allClasses + .SelectMany(c => c.QueryAllProperties()) + .Take(20); + + foreach (var property in properties) + { + var result = this.RenderWithPropertyContext("{{Property.WriteForPOCOInterface}}", property); + + Assert.That(result.Trim(), Is.Not.Empty, + $"WriteForPOCOInterface produced empty output for property {property.Name}"); + } + } + + // ------------------------------------------------------------------- + // Property.WriteTypeForExtendClass (context.Value = IProperty, must be derived) + // ------------------------------------------------------------------- + + [Test] + public void Verify_that_WriteTypeForExtendClass_generates_type_for_derived_property() + { + var result = this.RenderWithPropertyContext("{{Property.WriteTypeForExtendClass}}", this.derivedProperty); + + Assert.That(result.Trim(), Is.Not.Empty, + $"Expected type output for derived property {this.derivedProperty.Name}"); + } + + // ------------------------------------------------------------------- + // Property.WriteForDTOClass (parameters[0] = IProperty, parameters[1] = IClass) + // ------------------------------------------------------------------- + + [Test] + public void Verify_that_WriteForDTOClass_generates_property_for_each_class() + { + foreach (var @class in this.allClasses.Where(c => !c.IsAbstract).Take(5)) + { + var properties = @class.QueryAllNonDerivedNonRedefinedProperties(); + + foreach (var property in properties.Take(3)) + { + var result = this.RenderWithPropertyAndClassContext( + "{{Property.WriteForDTOClass this ../classObj}}", property, @class); + + Assert.That(result, Is.Not.Null, + $"WriteForDTOClass failed for property {property.Name} on class {@class.Name}"); + } + } + } + + // ------------------------------------------------------------------- + // Property.WriteForPOCOClass (context.Value = IProperty, arguments[1] = IClass) + // ------------------------------------------------------------------- + + [Test] + public void Verify_that_WriteForPOCOClass_generates_property() + { + var properties = this.testClass.QueryAllProperties().Take(3).ToArray(); + + foreach (var property in properties) + { + var result = this.RenderWithPropertyAndClassContext( + "{{Property.WriteForPOCOClass this ../classObj}}", property, this.testClass); + + Assert.That(result, Is.Not.Null, + $"WriteForPOCOClass failed for {property.Name}"); + } + } + + // ------------------------------------------------------------------- + // Property.WriteForDTOMessagePackFormatterSerialize + // ------------------------------------------------------------------- + + [Test] + public void Verify_that_WriteForDTOMessagePackFormatterSerialize_generates_code_for_non_derived_property() + { + var nonAbstractClass = this.allClasses.First(x => !x.IsAbstract); + + var nonDerivedProperty = nonAbstractClass.QueryAllProperties() + .FirstOrDefault(p => !p.IsDerived && !p.IsDerivedUnion && !p.IsReadOnly); + + if (nonDerivedProperty == null) + { + Assert.Ignore("No non-derived, non-readonly property found"); + } + + var result = this.RenderWithPropertyAndClassContext( + "{{Property.WriteForDTOMessagePackFormatterSerialize this ../classObj}}", nonDerivedProperty, nonAbstractClass); + + Assert.That(result, Is.Not.Null); + } + + [Test] + public void Verify_that_WriteForDTOMessagePackFormatterSerialize_produces_empty_for_derived_property() + { + var result = this.RenderWithPropertyAndClassContext( + "{{Property.WriteForDTOMessagePackFormatterSerialize this ../classObj}}", this.derivedProperty, this.testClass); + + Assert.That(result.Trim(), Is.Empty); + } + + // ------------------------------------------------------------------- + // Property.WriteForDTOMessagePackFormatterDeSerialize + // ------------------------------------------------------------------- + + [Test] + public void Verify_that_WriteForDTOMessagePackFormatterDeSerialize_generates_code() + { + var nonAbstractClass = this.allClasses.First(x => !x.IsAbstract); + + var nonDerivedProperty = nonAbstractClass.QueryAllProperties() + .FirstOrDefault(p => !p.IsDerived && !p.IsDerivedUnion && !p.IsReadOnly); + + if (nonDerivedProperty == null) + { + Assert.Ignore("No non-derived, non-readonly property found"); + } + + var result = this.RenderWithPropertyAndClassContext( + "{{Property.WriteForDTOMessagePackFormatterDeSerialize this ../classObj}}", nonDerivedProperty, nonAbstractClass); + + Assert.That(result, Is.Not.Null); + } + + // ------------------------------------------------------------------- + // Property.WriteForDTOComparer + // ------------------------------------------------------------------- + + [Test] + public void Verify_that_WriteForDTOComparer_generates_comparison_code() + { + var nonAbstractClass = this.allClasses.First(x => !x.IsAbstract); + + var nonDerivedNonRedefinedProperty = nonAbstractClass.QueryAllProperties() + .FirstOrDefault(p => !p.IsDerived && !p.IsDerivedUnion + && !p.TryQueryRedefinedByProperty(nonAbstractClass, out _)); + + if (nonDerivedNonRedefinedProperty == null) + { + Assert.Ignore("No suitable property found"); + } + + var result = this.RenderWithPropertyAndClassContext( + "{{Property.WriteForDTOComparer this ../classObj}}", nonDerivedNonRedefinedProperty, nonAbstractClass); + + Assert.That(result.Trim(), Is.Not.Empty); + Assert.That(result, Does.Contain("return false")); + } + + // ------------------------------------------------------------------- + // Boolean helpers (subexpression syntax with {{#each}} context) + // ------------------------------------------------------------------- + + [Test] + public void Verify_that_IsPropertyRedefinedInClass_can_be_evaluated() + { + var result = this.RenderWithPropertyAndClassContext( + "{{#if (Property.IsPropertyRedefinedInClass this ../classObj)}}YES{{else}}NO{{/if}}", + this.testProperty, this.testClass); + + Assert.That(result, Is.EqualTo("YES").Or.EqualTo("NO")); + } + + [Test] + public void Verify_that_IsRedefinedOrRedifines_can_be_evaluated() + { + var result = this.RenderWithPropertyAndClassContext( + "{{#if (Property.IsRedefinedOrRedifines this ../classObj)}}YES{{else}}NO{{/if}}", + this.testProperty, this.testClass); + + Assert.That(result, Is.EqualTo("YES").Or.EqualTo("NO")); + } + + [Test] + public void Verify_that_IsRedefinedByPropertyWithSameName_can_be_evaluated() + { + var result = this.RenderWithPropertyAndClassContext( + "{{#if (Property.IsRedefinedByPropertyWithSameName this ../classObj)}}YES{{else}}NO{{/if}}", + this.testProperty, this.testClass); + + Assert.That(result, Is.EqualTo("YES").Or.EqualTo("NO")); + } + + [Test] + public void Verify_that_IsOfTypeBaseElement_can_be_evaluated() + { + var result = this.RenderWithPropertyContext( + "{{#if (Property.IsOfTypeBaseElement this)}}YES{{else}}NO{{/if}}", + this.testProperty); + + Assert.That(result, Is.EqualTo("YES").Or.EqualTo("NO")); + } + + [Test] + public void Verify_that_QueryIsImpliedIncluded_returns_true_for_isImpliedIncluded_property() + { + var impliedIncludedProp = this.allClasses + .SelectMany(c => c.QueryAllProperties()) + .FirstOrDefault(p => p.Name == "isImpliedIncluded"); + + if (impliedIncludedProp == null) + { + Assert.Ignore("No isImpliedIncluded property found"); + } + + var result = this.RenderWithPropertyContext( + "{{#if (Property.QueryIsImpliedIncluded this)}}YES{{else}}NO{{/if}}", + impliedIncludedProp); + + Assert.That(result, Is.EqualTo("YES")); + } + + [Test] + public void Verify_that_QueryIsImpliedIncluded_returns_false_for_other_property() + { + var otherProp = this.allClasses + .SelectMany(c => c.QueryAllProperties()) + .First(p => p.Name != "isImpliedIncluded"); + + var result = this.RenderWithPropertyContext( + "{{#if (Property.QueryIsImpliedIncluded this)}}YES{{else}}NO{{/if}}", + otherProp); + + Assert.That(result, Is.EqualTo("NO")); + } + + [Test] + public void Verify_that_QueryHasDefaultValueWithDifferentValueThanDefault_can_be_evaluated() + { + var result = this.RenderWithPropertyContext( + "{{#if (Property.QueryHasDefaultValueWithDifferentValueThanDefault this)}}YES{{else}}NO{{/if}}", + this.testProperty); + + Assert.That(result, Is.EqualTo("YES").Or.EqualTo("NO")); + } + + [Test] + public void Verify_that_QueryIsEnumerableAndReferenceProperty_can_be_evaluated() + { + var result = this.RenderWithPropertyContext( + "{{#if (Property.QueryIsEnumerableAndReferenceProperty this)}}YES{{else}}NO{{/if}}", + this.testProperty); + + Assert.That(result, Is.EqualTo("YES").Or.EqualTo("NO")); + } + + [Test] + public void Verify_that_IsTypeAbstract_can_be_evaluated() + { + // Find a property whose Type supports IsAbstract without throwing + var safeProperty = this.allClasses + .SelectMany(c => c.QueryAllProperties()) + .FirstOrDefault(p => + { + try + { + var _ = p.Type is uml4net.Classification.IClassifier { IsAbstract: true }; + return true; + } + catch + { + return false; + } + }); + + if (safeProperty == null) + { + Assert.Ignore("No property with safe IsAbstract access found"); + } + + var result = this.RenderWithPropertyContext( + "{{#if (Property.IsTypeAbstract this)}}YES{{else}}NO{{/if}}", + safeProperty); + + Assert.That(result, Is.EqualTo("YES").Or.EqualTo("NO")); + } + + // ------------------------------------------------------------------- + // Property.WritePropertyName + // ------------------------------------------------------------------- + + [Test] + public void Verify_that_WritePropertyName_writes_property_name() + { + var result = this.RenderWithPropertyContext("{{Property.WritePropertyName this}}", this.testProperty); + + Assert.That(result.Trim(), Is.Not.Empty); + } + + // ------------------------------------------------------------------- + // Property.WritePropertyWithExplicitInterfaceIfRequiredForDTO + // ------------------------------------------------------------------- + + [Test] + public void Verify_that_WritePropertyWithExplicitInterfaceIfRequiredForDTO_writes_name() + { + var result = this.RenderWithPropertyAndClassContext( + "{{Property.WritePropertyWithExplicitInterfaceIfRequiredForDTO this ../classObj \"dto\"}}", + this.testProperty, this.testClass); + + Assert.That(result, Is.Not.Null.And.Not.Empty); + Assert.That(result, Does.Contain("dto.")); + } + + // ------------------------------------------------------------------- + // Property.WriteDefaultValue + // ------------------------------------------------------------------- + + [Test] + public void Verify_that_WriteDefaultValue_writes_value_for_property_with_default() + { + var propertyWithDefault = this.allClasses + .SelectMany(c => c.QueryAllProperties()) + .FirstOrDefault(p => p.QueryHasDefaultValue() && p.QueryIsDefaultValueDifferentThanDefault()); + + if (propertyWithDefault == null) + { + Assert.Ignore("No property with a non-default default value found"); + } + + var result = this.RenderWithPropertyContext("{{Property.WriteDefaultValue this}}", propertyWithDefault); + + Assert.That(result, Is.Not.Empty); + } + + // ------------------------------------------------------------------- + // Comprehensive tests + // ------------------------------------------------------------------- + + [Test] + public void Verify_that_WriteForDTOInterface_and_WriteForPOCOInterface_produce_output_for_all_classes() + { + foreach (var @class in this.allClasses.Take(5)) + { + foreach (var property in @class.QueryAllProperties().Take(5)) + { + var dtoResult = this.RenderWithPropertyContext("{{Property.WriteForDTOInterface}}", property); + Assert.That(dtoResult.Trim(), Is.Not.Empty, + $"WriteForDTOInterface empty for {@class.Name}.{property.Name}"); + + var pocoResult = this.RenderWithPropertyContext("{{Property.WriteForPOCOInterface}}", property); + Assert.That(pocoResult.Trim(), Is.Not.Empty, + $"WriteForPOCOInterface empty for {@class.Name}.{property.Name}"); + } + } + } + } +} diff --git a/SysML2.NET.CodeGenerator/Generators/UmlHandleBarsGenerators/UmlCoreXmiWriterGenerator.cs b/SysML2.NET.CodeGenerator/Generators/UmlHandleBarsGenerators/UmlCoreXmiWriterGenerator.cs new file mode 100644 index 000000000..61e1ba1d5 --- /dev/null +++ b/SysML2.NET.CodeGenerator/Generators/UmlHandleBarsGenerators/UmlCoreXmiWriterGenerator.cs @@ -0,0 +1,194 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.CodeGenerator.Generators.UmlHandleBarsGenerators +{ + using System; + using System.IO; + using System.Linq; + using System.Threading.Tasks; + + using SysML2.NET.CodeGenerator.Extensions; + using SysML2.NET.CodeGenerator.HandleBarHelpers; + + using uml4net.Extensions; + using uml4net.StructuredClassifiers; + using uml4net.xmi.Readers; + + /// + /// A UML Handlebars based XMI Writer code generator + /// + public class UmlCoreXmiWriterGenerator : UmlHandleBarsGenerator + { + /// + /// Gets the name of the Xmi Writer template + /// + private const string XmiWriterTemplateName = "core-xmi-writer-template"; + + /// + /// Gets the name of the Xmi Writer Facade template + /// + private const string XmiWriterFacadeTemplateName = "core-xmi-writer-facade-template"; + + /// + /// Generates code specific to the concrete implementation + /// + /// + /// the that contains the UML model to generate from + /// + /// + /// The target + /// + /// + /// an awaitable + /// + public override async Task GenerateAsync(XmiReaderResult xmiReaderResult, DirectoryInfo outputDirectory) + { + await this.GenerateXmiWriters(xmiReaderResult, outputDirectory); + await this.GenerateXmiWriterFacade(xmiReaderResult, outputDirectory); + } + + /// + /// Generates XMI Writer classes for all concrete + /// + /// the that contains the UML model to generate from + /// + /// The target + /// + /// + /// an awaitable + /// + /// + /// In case of null value for or + /// + /// + private Task GenerateXmiWriters(XmiReaderResult xmiReaderResult, DirectoryInfo outputDirectory) + { + ArgumentNullException.ThrowIfNull(xmiReaderResult); + ArgumentNullException.ThrowIfNull(outputDirectory); + + return this.GenerateXmiWritersInternal(xmiReaderResult, outputDirectory); + } + + /// + /// Generates XMI Writer classes for all concrete + /// + /// the that contains the UML model to generate from + /// + /// The target + /// + /// + /// an awaitable + /// + private async Task GenerateXmiWritersInternal(XmiReaderResult xmiReaderResult, DirectoryInfo outputDirectory) + { + var template = this.Templates[XmiWriterTemplateName]; + + var classes = xmiReaderResult.QueryContainedAndImported("SysML") + .SelectMany(x => x.PackagedElement.OfType()) + .Where(x => !x.IsAbstract) + .ToList(); + + foreach (var umlClass in classes) + { + var generatedXmiWriter = template(umlClass); + + generatedXmiWriter = this.CodeCleanup(generatedXmiWriter); + + var fileName = $"{umlClass.Name.CapitalizeFirstLetter()}Writer.cs"; + await WriteAsync(generatedXmiWriter, outputDirectory, fileName); + } + } + + /// + /// Generates XMI Writer facade class for all concrete + /// + /// the that contains the UML model to generate from + /// + /// The target + /// + /// + /// an awaitable + /// + /// + /// In case of null value for or + /// + /// + private Task GenerateXmiWriterFacade(XmiReaderResult xmiReaderResult, DirectoryInfo outputDirectory) + { + ArgumentNullException.ThrowIfNull(xmiReaderResult); + ArgumentNullException.ThrowIfNull(outputDirectory); + + return this.GenerateXmiWriterFacadeInternal(xmiReaderResult, outputDirectory); + } + + /// + /// Generates XMI Writer facade class for all concrete + /// + /// the that contains the UML model to generate from + /// + /// The target + /// + /// + /// an awaitable + /// + private async Task GenerateXmiWriterFacadeInternal(XmiReaderResult xmiReaderResult, DirectoryInfo outputDirectory) + { + var template = this.Templates[XmiWriterFacadeTemplateName]; + + var classes = xmiReaderResult.QueryContainedAndImported("SysML") + .SelectMany(x => x.PackagedElement.OfType()) + .Where(x => !x.IsAbstract) + .OrderBy(x => x.Name) + .ToList(); + + var generatedFacade = template(classes); + generatedFacade = this.CodeCleanup(generatedFacade); + await WriteAsync(generatedFacade, outputDirectory, "XmiDataWriterFacade.cs"); + } + + /// + /// Register the custom helpers + /// + protected override void RegisterHelpers() + { + this.Handlebars.RegisterNamedElementHelper(); + this.Handlebars.RegisterSafeContextHelper(); + this.Handlebars.RegisterClassHelper(); + SysML2.NET.CodeGenerator.HandleBarHelpers.PropertyHelper.RegisterPropertyHelper(this.Handlebars); + uml4net.HandleBars.StringHelper.RegisterStringHelper(this.Handlebars); + uml4net.HandleBars.ClassHelper.RegisterClassHelper(this.Handlebars); + uml4net.HandleBars.PropertyHelper.RegisterPropertyHelper(this.Handlebars); + } + + /// + /// Register the code templates + /// + protected override void RegisterTemplates() + { + this.RegisterTemplate(XmiWriterTemplateName); + this.RegisterTemplate(XmiWriterFacadeTemplateName); + this.RegisterPartialTemplate("core-xmi-writer-partial-for-attribute-template"); + this.RegisterPartialTemplate("core-xmi-writer-partial-for-element-template"); + this.RegisterPartialTemplate("core-xmi-writer-partial-for-attribute-async-template"); + this.RegisterPartialTemplate("core-xmi-writer-partial-for-element-async-template"); + } + } +} diff --git a/SysML2.NET.CodeGenerator/HandleBarHelpers/ClassHelper.cs b/SysML2.NET.CodeGenerator/HandleBarHelpers/ClassHelper.cs index 53140d8d3..3446e7354 100644 --- a/SysML2.NET.CodeGenerator/HandleBarHelpers/ClassHelper.cs +++ b/SysML2.NET.CodeGenerator/HandleBarHelpers/ClassHelper.cs @@ -195,6 +195,16 @@ public static void RegisterClassHelper(this IHandlebars handlebars) var properties = umlClass.QueryAllProperties(); return properties.Where(x => x.IsComposite && !x.IsDerived); }); + + handlebars.RegisterHelper("Class.QueryAllPropertiesSorted", (context, _) => + { + if (context.Value is not IClass umlClass) + { + throw new ArgumentException("Class.QueryAllPropertiesSorted context supposed to be IClass"); + } + + return umlClass.QueryAllProperties().OrderBy(x => x.Name); + }); } } } diff --git a/SysML2.NET.CodeGenerator/HandleBarHelpers/PropertyHelper.cs b/SysML2.NET.CodeGenerator/HandleBarHelpers/PropertyHelper.cs index 85f8861ce..f46a4c938 100644 --- a/SysML2.NET.CodeGenerator/HandleBarHelpers/PropertyHelper.cs +++ b/SysML2.NET.CodeGenerator/HandleBarHelpers/PropertyHelper.cs @@ -1016,6 +1016,16 @@ public static void RegisterPropertyHelper(this IHandlebars handlebars) return property.Type.Name == "Element"; }); + handlebars.RegisterHelper("Property.QueryIsImpliedIncluded", (_, arguments) => + { + if (arguments.Single() is not IProperty property) + { + throw new ArgumentException("The #Property.QueryIsImpliedIncluded argument supposed to be IProperty"); + } + + return property.Name == "isImpliedIncluded"; + }); + handlebars.RegisterHelper("Property.WriteForNonDerivedCompositeAggregation", (writer, context, _) => { if (context.Value is not IProperty property) @@ -1037,7 +1047,80 @@ public static void RegisterPropertyHelper(this IHandlebars handlebars) stringBuilder.AppendLine($"{childVariableName} => {childVariableName}.{oppositePropertyName});"); writer.WriteSafeString(stringBuilder + Environment.NewLine); }); - } + + handlebars.RegisterHelper("Property.QueryHasDefaultValueWithDifferentValueThanDefault", (_, arguments) => + { + if (arguments.Length != 1) + { + throw new ArgumentException("The #Property.QueryHasDefaultValueWithDifferentValueThanDefault supposed to have one argument"); + } + + if (arguments[0] is not IProperty property) + { + throw new ArgumentException("The #Property.QueryHasDefaultValueWithDifferentValueThanDefault argument supposed to be an IProperty"); + } + + return property.QueryIsEnum() + ? property.QueryIsEnumPropertyWithDefaultValue() + : (property.QueryHasDefaultValue() && property.QueryIsDefaultValueDifferentThanDefault()); + }); + + handlebars.RegisterHelper("Property.WriteDefaultValue", (writer, _, arguments) => + { + if (arguments.Length != 1) + { + throw new ArgumentException("The #Property.WriteDefaultValue supposed to have one argument"); + } + + if (arguments[0] is not IProperty property) + { + throw new ArgumentException("The #Property.WriteDefaultValue argument supposed to be an IProperty"); + } + + if (property.QueryIsEnum()) + { + writer.WriteSafeString($"{property.Type.Name}.{property.QueryDefaultValueAsString().CapitalizeFirstLetter()}"); + } + else if (property.QueryIsString()) + { + writer.WriteSafeString($"\"{property.QueryDefaultValueAsString()}\""); + } + else + { + writer.WriteSafeString($"{property.QueryDefaultValueAsString()}"); + } + }); + + handlebars.RegisterHelper("Property.QueryIsEnumerableAndReferenceProperty", (_, arguments) => + { + if (arguments.Length != 1) + { + throw new ArgumentException("The #Property.QueryIsEnumerableAndReferenceProperty supposed to have one argument"); + } + + if (arguments[0] is not IProperty property) + { + throw new ArgumentException("The #Property.QueryIsEnumerableAndReferenceProperty argument supposed to be an IProperty"); + } + + return property.QueryIsEnumerable() && property.QueryIsReferenceProperty(); + }); + + handlebars.RegisterHelper("Property.IsTypeAbstract", (_, arguments) => + { + if (arguments.Length != 1) + { + throw new ArgumentException("The #Property.IsTypeAbstract supposed to have one argument"); + } + + if (arguments[0] is not IProperty property) + { + throw new ArgumentException("The #Property.IsTypeAbstract argument supposed to be an IProperty"); + } + + return property.Type is IClassifier { IsAbstract: true }; + }); + } /// /// Gets the getter implementation for an that has been redefined, for DTO generation diff --git a/SysML2.NET.CodeGenerator/SysML2.NET.CodeGenerator.csproj b/SysML2.NET.CodeGenerator/SysML2.NET.CodeGenerator.csproj index a14690e29..a3dafa207 100644 --- a/SysML2.NET.CodeGenerator/SysML2.NET.CodeGenerator.csproj +++ b/SysML2.NET.CodeGenerator/SysML2.NET.CodeGenerator.csproj @@ -211,6 +211,24 @@ Always + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + diff --git a/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-reader-partial-for-attribute-template.hbs b/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-reader-partial-for-attribute-template.hbs index adb1294dd..3c34ee8a8 100644 --- a/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-reader-partial-for-attribute-template.hbs +++ b/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-reader-partial-for-attribute-template.hbs @@ -5,15 +5,19 @@ if(!string.IsNullOrWhiteSpace({{String.LowerCaseFirstLetter property.Name}}XmlAt {{#if (Property.QueryIsReferenceProperty property)}} {{#if (Property.QueryIsEnumerable property)}} var {{String.LowerCaseFirstLetter property.Name}}XmlAttributeReferences = new List(); - + foreach(var {{String.LowerCaseFirstLetter property.Name}}XmlAttributeValue in {{String.LowerCaseFirstLetter property.Name}}XmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries)) { if(Guid.TryParse({{String.LowerCaseFirstLetter property.Name}}XmlAttributeValue, out var {{String.LowerCaseFirstLetter property.Name}}XmlAttributeReference)) { {{String.LowerCaseFirstLetter property.Name}}XmlAttributeReferences.Add({{String.LowerCaseFirstLetter property.Name}}XmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property '{{String.LowerCaseFirstLetter property.Name}}' on element {ElementId}", {{String.LowerCaseFirstLetter property.Name}}XmlAttributeValue, poco.Id); + } } - + if({{String.LowerCaseFirstLetter property.Name}}XmlAttributeReferences.Count != 0) { this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "{{String.LowerCaseFirstLetter property.Name}}", {{String.LowerCaseFirstLetter property.Name}}XmlAttributeReferences); @@ -23,6 +27,10 @@ if(!string.IsNullOrWhiteSpace({{String.LowerCaseFirstLetter property.Name}}XmlAt { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "{{String.LowerCaseFirstLetter property.Name}}", {{String.LowerCaseFirstLetter property.Name}}XmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property '{{String.LowerCaseFirstLetter property.Name}}' on element {ElementId}", {{String.LowerCaseFirstLetter property.Name}}XmlAttribute, poco.Id); + } {{/if}} {{else}} {{#if (Property.QueryIsEnumerable property)}} @@ -34,7 +42,7 @@ if(!string.IsNullOrWhiteSpace({{String.LowerCaseFirstLetter property.Name}}XmlAt poco.{{Property.WritePropertyName property}}.Add({{String.LowerCaseFirstLetter property.Name}}XmlAttributeValueAsBool); } {{else if (Property.QueryIsEnum property )}} - if(Enum.TryParse({{String.LowerCaseFirstLetter property.Name}}XmlAttributeValue, true, out {{property.Type.Name}} {{String.LowerCaseFirstLetter property.Name}}XmlAttributeValueAsEnum)) + if({{property.Type.Name}}Provider.TryParse({{String.LowerCaseFirstLetter property.Name}}XmlAttributeValue.AsSpan(), out var {{String.LowerCaseFirstLetter property.Name}}XmlAttributeValueAsEnum)) { poco.{{Property.WritePropertyName property}}.Add({{String.LowerCaseFirstLetter property.Name}}XmlAttributeValueAsEnum); } @@ -63,7 +71,7 @@ if(!string.IsNullOrWhiteSpace({{String.LowerCaseFirstLetter property.Name}}XmlAt poco.{{Property.WritePropertyName property}} = {{String.LowerCaseFirstLetter property.Name}}XmlAttributeAsBool; } {{else if (Property.QueryIsEnum property )}} - if(Enum.TryParse({{String.LowerCaseFirstLetter property.Name}}XmlAttribute, true, out {{property.Type.Name}} {{String.LowerCaseFirstLetter property.Name}}XmlAttributeAsEnum)) + if({{property.Type.Name}}Provider.TryParse({{String.LowerCaseFirstLetter property.Name}}XmlAttribute.AsSpan(), out var {{String.LowerCaseFirstLetter property.Name}}XmlAttributeAsEnum)) { poco.{{Property.WritePropertyName property}} = {{String.LowerCaseFirstLetter property.Name}}XmlAttributeAsEnum; } diff --git a/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-reader-partial-for-element-template.hbs b/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-reader-partial-for-element-template.hbs index 96ad1f324..68f925690 100644 --- a/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-reader-partial-for-element-template.hbs +++ b/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-reader-partial-for-element-template.hbs @@ -2,24 +2,30 @@ case"{{String.LowerCaseFirstLetter property.Name}}": { {{#if (Property.QueryIsReferenceProperty property)}} var hrefAttribute = xmiReader.GetAttribute("href"); - + if(!string.IsNullOrWhiteSpace(hrefAttribute)) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var {{String.LowerCaseFirstLetter property.Name}}Id = Guid.Parse(hrefSplit[1]); - {{#if (Property.QueryIsEnumerable property)}} - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "{{String.LowerCaseFirstLetter property.Name}}", {{String.LowerCaseFirstLetter property.Name}}Id); - {{else}} - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "{{String.LowerCaseFirstLetter property.Name}}", {{String.LowerCaseFirstLetter property.Name}}Id); - {{/if}} + if(Guid.TryParse(hrefSplit[1], out var {{String.LowerCaseFirstLetter property.Name}}Id)) + { + {{#if (Property.QueryIsEnumerable property)}} + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "{{String.LowerCaseFirstLetter property.Name}}", {{String.LowerCaseFirstLetter property.Name}}Id); + {{else}} + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "{{String.LowerCaseFirstLetter property.Name}}", {{String.LowerCaseFirstLetter property.Name}}Id); + {{/if}} + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property '{{String.LowerCaseFirstLetter property.Name}}' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { {{#if asyncState}} - var {{String.LowerCaseFirstLetter property.Name}}Value = (I{{property.Type.Name}})await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var {{String.LowerCaseFirstLetter property.Name}}Value = (I{{property.Type.Name}})await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); {{else}} - var {{String.LowerCaseFirstLetter property.Name}}Value = (I{{property.Type.Name}})this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var {{String.LowerCaseFirstLetter property.Name}}Value = (I{{property.Type.Name}})this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); {{/if}} {{#if (Property.QueryIsEnumerable property)}} @@ -42,19 +48,47 @@ case"{{String.LowerCaseFirstLetter property.Name}}": {{else}} var {{String.LowerCaseFirstLetter property.Name}}Value = xmiReader.ReadElementContentAsString(); {{/if}} - + if(!string.IsNullOrWhiteSpace({{String.LowerCaseFirstLetter property.Name}}Value)) { {{#if (Property.QueryIsEnumerable property)}} {{#if (Property.QueryIsBool property )}} - poco.{{Property.WritePropertyName property}}.Add(bool.Parse({{String.LowerCaseFirstLetter property.Name}}Value)); + if(bool.TryParse({{String.LowerCaseFirstLetter property.Name}}Value, out var {{String.LowerCaseFirstLetter property.Name}}ValueAsBool)) + { + poco.{{Property.WritePropertyName property}}.Add({{String.LowerCaseFirstLetter property.Name}}ValueAsBool); + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property '{{String.LowerCaseFirstLetter property.Name}}' on element {ElementId}", {{String.LowerCaseFirstLetter property.Name}}Value, poco.Id); + } {{else if (Property.QueryIsEnum property )}} - poco.{{Property.WritePropertyName property}}.Add(({{property.Type.Name}})Enum.Parse(typeof({{property.Type.Name}}), {{String.LowerCaseFirstLetter property.Name}}Value, true)); + if({{property.Type.Name}}Provider.TryParse({{String.LowerCaseFirstLetter property.Name}}Value.AsSpan(), out var {{String.LowerCaseFirstLetter property.Name}}ValueAsEnum)) + { + poco.{{Property.WritePropertyName property}}.Add({{String.LowerCaseFirstLetter property.Name}}ValueAsEnum); + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property '{{String.LowerCaseFirstLetter property.Name}}' on element {ElementId}", {{String.LowerCaseFirstLetter property.Name}}Value, poco.Id); + } {{else if (Property.QueryIsNumeric property )}} {{#if (Property.QueryIsInteger property) }} - poco.{{Property.WritePropertyName property}}.Add(int.Parse({{String.LowerCaseFirstLetter property.Name}}Value)); + if(int.TryParse({{String.LowerCaseFirstLetter property.Name}}Value, out var {{String.LowerCaseFirstLetter property.Name}}ValueAsInt)) + { + poco.{{Property.WritePropertyName property}}.Add({{String.LowerCaseFirstLetter property.Name}}ValueAsInt); + } + else + { + this.logger.LogWarning("Failed to parse int value '{Value}' for property '{{String.LowerCaseFirstLetter property.Name}}' on element {ElementId}", {{String.LowerCaseFirstLetter property.Name}}Value, poco.Id); + } {{else if (Property.QueryIsDouble property) }} - poco.{{Property.WritePropertyName property}}.Add(double.Parse({{String.LowerCaseFirstLetter property.Name}}Value)); + if(double.TryParse({{String.LowerCaseFirstLetter property.Name}}Value, out var {{String.LowerCaseFirstLetter property.Name}}ValueAsDouble)) + { + poco.{{Property.WritePropertyName property}}.Add({{String.LowerCaseFirstLetter property.Name}}ValueAsDouble); + } + else + { + this.logger.LogWarning("Failed to parse double value '{Value}' for property '{{String.LowerCaseFirstLetter property.Name}}' on element {ElementId}", {{String.LowerCaseFirstLetter property.Name}}Value, poco.Id); + } {{ else }} new NotImplementedException("{{ classContext.Name }}.{{property.Name}} is not yet supported"); {{/if}} @@ -63,14 +97,42 @@ case"{{String.LowerCaseFirstLetter property.Name}}": {{/if}} {{else}} {{#if (Property.QueryIsBool property )}} - poco.{{Property.WritePropertyName property}} = bool.Parse({{String.LowerCaseFirstLetter property.Name}}Value); + if(bool.TryParse({{String.LowerCaseFirstLetter property.Name}}Value, out var {{String.LowerCaseFirstLetter property.Name}}ValueAsBool)) + { + poco.{{Property.WritePropertyName property}} = {{String.LowerCaseFirstLetter property.Name}}ValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property '{{String.LowerCaseFirstLetter property.Name}}' on element {ElementId}", {{String.LowerCaseFirstLetter property.Name}}Value, poco.Id); + } {{else if (Property.QueryIsEnum property )}} - poco.{{Property.WritePropertyName property}} = ({{property.Type.Name}})Enum.Parse(typeof({{property.Type.Name}}), {{String.LowerCaseFirstLetter property.Name}}Value, true); + if({{property.Type.Name}}Provider.TryParse({{String.LowerCaseFirstLetter property.Name}}Value.AsSpan(), out var {{String.LowerCaseFirstLetter property.Name}}ValueAsEnum)) + { + poco.{{Property.WritePropertyName property}} = {{String.LowerCaseFirstLetter property.Name}}ValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property '{{String.LowerCaseFirstLetter property.Name}}' on element {ElementId}", {{String.LowerCaseFirstLetter property.Name}}Value, poco.Id); + } {{else if (Property.QueryIsNumeric property )}} {{#if (Property.QueryIsInteger property) }} - poco.{{Property.WritePropertyName property}} = int.Parse({{String.LowerCaseFirstLetter property.Name}}Value); + if(int.TryParse({{String.LowerCaseFirstLetter property.Name}}Value, out var {{String.LowerCaseFirstLetter property.Name}}ValueAsInt)) + { + poco.{{Property.WritePropertyName property}} = {{String.LowerCaseFirstLetter property.Name}}ValueAsInt; + } + else + { + this.logger.LogWarning("Failed to parse int value '{Value}' for property '{{String.LowerCaseFirstLetter property.Name}}' on element {ElementId}", {{String.LowerCaseFirstLetter property.Name}}Value, poco.Id); + } {{else if (Property.QueryIsDouble property) }} - poco.{{Property.WritePropertyName property}} = double.Parse({{String.LowerCaseFirstLetter property.Name}}Value); + if(double.TryParse({{String.LowerCaseFirstLetter property.Name}}Value, out var {{String.LowerCaseFirstLetter property.Name}}ValueAsDouble)) + { + poco.{{Property.WritePropertyName property}} = {{String.LowerCaseFirstLetter property.Name}}ValueAsDouble; + } + else + { + this.logger.LogWarning("Failed to parse double value '{Value}' for property '{{String.LowerCaseFirstLetter property.Name}}' on element {ElementId}", {{String.LowerCaseFirstLetter property.Name}}Value, poco.Id); + } {{ else }} new NotImplementedException("{{ classContext.Name }}.{{property.Name}} is not yet supported"); {{/if}} diff --git a/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-writer-partial-for-attribute-async-template.hbs b/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-writer-partial-for-attribute-async-template.hbs new file mode 100644 index 000000000..60e66b15f --- /dev/null +++ b/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-writer-partial-for-attribute-async-template.hbs @@ -0,0 +1,70 @@ +{{#if (Property.QueryIsEnumerable property)}} + {{#unless (Property.QueryIsReferenceProperty property)}} + {{#if (Property.QueryIsBool property)}} + if(poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, string.Join(" ", poco.{{Property.WritePropertyName property}})); + } + {{else}} + if(poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, string.Join(" ", poco.{{Property.WritePropertyName property}})); + } + {{/if}} + {{/unless}} +{{else}} + {{#if (Property.QueryIsReferenceProperty property)}} + if(writerOptions.WriteIdRefAsAttribute && poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, poco.{{Property.WritePropertyName property}}.Id.ToString()); + } + {{else}} + {{#if (Property.QueryHasDefaultValueWithDifferentValueThanDefault property)}} + {{#unless (Property.QueryIsBool property)}} + if(poco.{{Property.WritePropertyName property}} != {{Property.WriteDefaultValue property}}) + { + {{/unless}} + {{/if}} + {{#if (Property.QueryIsBool property)}} + {{#if (Property.QueryIsImpliedIncluded property)}} + if(writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + {{else}} + {{#if (Property.QueryHasDefaultValueWithDifferentValueThanDefault property)}} + if(!poco.{{Property.WritePropertyName property}}) + { + await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, "false"); + } + {{else}} + if(poco.{{Property.WritePropertyName property}}) + { + await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, "true"); + } + {{/if}} + {{/if}} + {{else if (Property.QueryIsEnum property)}} + {{#if (Property.QueryIsNullable property)}} + if(poco.{{Property.WritePropertyName property}}.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, poco.{{Property.WritePropertyName property}}.Value.ToString().ToLower()); + } + {{else}} + await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, poco.{{Property.WritePropertyName property}}.ToString().ToLower()); + {{/if}} + {{else if (Property.QueryIsNumeric property)}} + await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, poco.{{Property.WritePropertyName property}}.ToString(CultureInfo.InvariantCulture)); + {{else}} + if(!string.IsNullOrWhiteSpace(poco.{{Property.WritePropertyName property}})) + { + await xmlWriter.WriteAttributeStringAsync(null, "{{String.LowerCaseFirstLetter property.Name}}", null, poco.{{Property.WritePropertyName property}}); + } + {{/if}} + {{#if (Property.QueryHasDefaultValueWithDifferentValueThanDefault property)}} + {{#unless (Property.QueryIsBool property)}} + } + {{/unless}} + {{/if}} + {{/if}} +{{/if}} diff --git a/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-writer-partial-for-attribute-template.hbs b/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-writer-partial-for-attribute-template.hbs new file mode 100644 index 000000000..90355107c --- /dev/null +++ b/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-writer-partial-for-attribute-template.hbs @@ -0,0 +1,70 @@ +{{#if (Property.QueryIsEnumerable property)}} + {{#unless (Property.QueryIsReferenceProperty property)}} + {{#if (Property.QueryIsBool property)}} + if(poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.Count > 0) + { + xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", string.Join(" ", poco.{{Property.WritePropertyName property}})); + } + {{else}} + if(poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.Count > 0) + { + xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", string.Join(" ", poco.{{Property.WritePropertyName property}})); + } + {{/if}} + {{/unless}} +{{else}} + {{#if (Property.QueryIsReferenceProperty property)}} + if(writerOptions.WriteIdRefAsAttribute && poco.{{Property.WritePropertyName property}} != null && poco.{{Property.WritePropertyName property}}.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", poco.{{Property.WritePropertyName property}}.Id.ToString()); + } + {{else}} + {{#if (Property.QueryHasDefaultValueWithDifferentValueThanDefault property)}} + {{#unless (Property.QueryIsBool property)}} + if(poco.{{Property.WritePropertyName property}} != {{Property.WriteDefaultValue property}}) + { + {{/unless}} + {{/if}} + {{#if (Property.QueryIsBool property)}} + {{#if (Property.QueryIsImpliedIncluded property)}} + if(writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + {{else}} + {{#if (Property.QueryHasDefaultValueWithDifferentValueThanDefault property)}} + if(!poco.{{Property.WritePropertyName property}}) + { + xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", "false"); + } + {{else}} + if(poco.{{Property.WritePropertyName property}}) + { + xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", "true"); + } + {{/if}} + {{/if}} + {{else if (Property.QueryIsEnum property)}} + {{#if (Property.QueryIsNullable property)}} + if(poco.{{Property.WritePropertyName property}}.HasValue) + { + xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", poco.{{Property.WritePropertyName property}}.Value.ToString().ToLower()); + } + {{else}} + xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", poco.{{Property.WritePropertyName property}}.ToString().ToLower()); + {{/if}} + {{else if (Property.QueryIsNumeric property)}} + xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", poco.{{Property.WritePropertyName property}}.ToString(CultureInfo.InvariantCulture)); + {{else}} + if(!string.IsNullOrWhiteSpace(poco.{{Property.WritePropertyName property}})) + { + xmlWriter.WriteAttributeString("{{String.LowerCaseFirstLetter property.Name}}", poco.{{Property.WritePropertyName property}}); + } + {{/if}} + {{#if (Property.QueryHasDefaultValueWithDifferentValueThanDefault property)}} + {{#unless (Property.QueryIsBool property)}} + } + {{/unless}} + {{/if}} + {{/if}} +{{/if}} diff --git a/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-writer-partial-for-element-async-template.hbs b/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-writer-partial-for-element-async-template.hbs new file mode 100644 index 000000000..be4920bb9 --- /dev/null +++ b/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-writer-partial-for-element-async-template.hbs @@ -0,0 +1,25 @@ +{{#if (Property.QueryIsEnumerable property)}} + if(poco.{{Property.WritePropertyName property}} != null) + { + foreach(var item in poco.{{Property.WritePropertyName property}}) + { + {{#if property.IsComposite}} + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "{{String.LowerCaseFirstLetter property.Name}}", writerOptions, elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}}); + {{else}} + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "{{String.LowerCaseFirstLetter property.Name}}", elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}}); + {{/if}} + } + } +{{else}} + if(poco.{{Property.WritePropertyName property}} != null) + { + {{#if property.IsComposite}} + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.{{Property.WritePropertyName property}}, "{{String.LowerCaseFirstLetter property.Name}}", writerOptions, elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}}); + {{else}} + if(!writerOptions.WriteIdRefAsAttribute || !poco.{{Property.WritePropertyName property}}.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.{{Property.WritePropertyName property}}, "{{String.LowerCaseFirstLetter property.Name}}", elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}}); + } + {{/if}} + } +{{/if}} diff --git a/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-writer-partial-for-element-template.hbs b/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-writer-partial-for-element-template.hbs new file mode 100644 index 000000000..e7e8da642 --- /dev/null +++ b/SysML2.NET.CodeGenerator/Templates/Uml/Partials/core-xmi-writer-partial-for-element-template.hbs @@ -0,0 +1,25 @@ +{{#if (Property.QueryIsEnumerable property)}} + if(poco.{{Property.WritePropertyName property}} != null) + { + foreach(var item in poco.{{Property.WritePropertyName property}}) + { + {{#if property.IsComposite}} + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "{{String.LowerCaseFirstLetter property.Name}}", writerOptions, elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}}); + {{else}} + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "{{String.LowerCaseFirstLetter property.Name}}", elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}}); + {{/if}} + } + } +{{else}} + if(poco.{{Property.WritePropertyName property}} != null) + { + {{#if property.IsComposite}} + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.{{Property.WritePropertyName property}}, "{{String.LowerCaseFirstLetter property.Name}}", writerOptions, elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}}); + {{else}} + if(!writerOptions.WriteIdRefAsAttribute || !poco.{{Property.WritePropertyName property}}.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.{{Property.WritePropertyName property}}, "{{String.LowerCaseFirstLetter property.Name}}", elementOriginMap, currentFileUri{{#if property.Type.IsAbstract}}, true{{/if}}); + } + {{/if}} + } +{{/if}} diff --git a/SysML2.NET.CodeGenerator/Templates/Uml/core-enumprovider-uml-template.hbs b/SysML2.NET.CodeGenerator/Templates/Uml/core-enumprovider-uml-template.hbs index b67b1e976..205bd01f5 100644 --- a/SysML2.NET.CodeGenerator/Templates/Uml/core-enumprovider-uml-template.hbs +++ b/SysML2.NET.CodeGenerator/Templates/Uml/core-enumprovider-uml-template.hbs @@ -65,6 +65,38 @@ namespace SysML2.NET.Extensions.Core throw new ArgumentException($"'{new string(value)}' is not a valid {{ this.Name }}", nameof(value)); } + /// + /// Tries to parse the to a + /// + /// + /// The that is to be parsed + /// + /// + /// When this method returns, contains the value equivalent + /// to the span, if the conversion succeeded, or default if the conversion failed. + /// + /// + /// true if was converted successfully; otherwise, false. + /// + /// + /// This method is suited for string parsing + /// There are zero allocations, no boxing, Fast short-circuit evaluation + /// JIT friendly + /// + public static bool TryParse(ReadOnlySpan value, out {{ this.Name }} result) + { + {{ #each this.OwnedLiteral as | enumerationLiteral | }} + if (value.Length == {{ String.Length enumerationLiteral.Name }} && value.Equals("{{ enumerationLiteral.Name }}".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = {{ ../Name }}.{{ #EnumerationLiteral.Write enumerationLiteral }}; + return true; + } + + {{/each}} + result = default; + return false; + } + /// /// Parses the to a /// diff --git a/SysML2.NET.CodeGenerator/Templates/Uml/core-xmi-reader-facade-template.hbs b/SysML2.NET.CodeGenerator/Templates/Uml/core-xmi-reader-facade-template.hbs index d216e82a8..99097cf76 100644 --- a/SysML2.NET.CodeGenerator/Templates/Uml/core-xmi-reader-facade-template.hbs +++ b/SysML2.NET.CodeGenerator/Templates/Uml/core-xmi-reader-facade-template.hbs @@ -44,38 +44,38 @@ namespace SysML2.NET.Serializer.Xmi.Readers /// A dictionary that contains functions that return based a key that represents the xsi Type /// and a provided , , and /// - private readonly Dictionary> readerCache; + private readonly Dictionary> readerCache; /// /// A dictionary that contains functions that return an awaitable with the based a key that represents the xsi Type /// and a provided , , and /// - private readonly Dictionary>> readerAsyncCache; + private readonly Dictionary>> readerAsyncCache; /// /// Initializes a new instance of the /// public XmiDataReaderFacade() { - this.readerCache = new Dictionary> + this.readerCache = new Dictionary> { {{ #each this as | class | }} - ["sysml:{{ class.Name }}"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:{{ class.Name }}"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var {{ String.LowerCaseFirstLetter class.Name }}Reader = new {{ class.Name }}Reader(cache, this, externalReferenceService, loggerFactory); + var {{ String.LowerCaseFirstLetter class.Name }}Reader = new {{ class.Name }}Reader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return {{ String.LowerCaseFirstLetter class.Name }}Reader.Read(subXmlReader, currentLocation); }, {{/each}} }; - this.readerAsyncCache = new Dictionary>> + this.readerAsyncCache = new Dictionary>> { {{ #each this as | class | }} - ["sysml:{{ class.Name }}"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:{{ class.Name }}"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var {{ String.LowerCaseFirstLetter class.Name }}Reader = new {{ class.Name }}Reader(cache, this, externalReferenceService, loggerFactory); + var {{ String.LowerCaseFirstLetter class.Name }}Reader = new {{ class.Name }}Reader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await {{ String.LowerCaseFirstLetter class.Name }}Reader.ReadAsync(subXmlReader, currentLocation); }, {{/each}} @@ -95,7 +95,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers /// The explicit type name to resolve, in case of un-specified xsi:type /// An instance of the read /// If the xsi:type is not supported - public IData QueryXmiData(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = "") + public IData QueryXmiData(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = "", IXmiElementOriginMap elementOriginMap = null) { AssertValidQueryXmiDataParameters(xmiReader, xmiDataCache, currentLocation); @@ -107,12 +107,12 @@ namespace SysML2.NET.Serializer.Xmi.Readers } xsiType ??= explicitTypeName; - + if (this.readerCache.TryGetValue(xsiType, out var readerFactory)) { - return readerFactory(xmiDataCache, externalReferenceService, loggerFactory, xmiReader, currentLocation); + return readerFactory(xmiDataCache, externalReferenceService, loggerFactory, xmiReader, currentLocation, elementOriginMap); } - + throw new InvalidOperationException($"No reader found for xsi:type - {xsiType}"); } @@ -129,24 +129,24 @@ namespace SysML2.NET.Serializer.Xmi.Readers /// The explicit type name to resolve, in case of un-specified xsi:type /// An awaitable with the instance of the read /// If the xsi:type is not supported - public Task QueryXmiDataAsync(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = "") + public Task QueryXmiDataAsync(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = "", IXmiElementOriginMap elementOriginMap = null) { AssertValidQueryXmiDataParameters(xmiReader, xmiDataCache, currentLocation); - + var xsiType = xmiReader.GetAttribute("xsi:type"); - + if (xsiType == null && string.IsNullOrEmpty(explicitTypeName)) { throw new InvalidOperationException($"The xsi:type is not specified"); } - + xsiType ??= explicitTypeName; - + if (this.readerAsyncCache.TryGetValue(xsiType, out var readerFactory)) { - return readerFactory(xmiDataCache, externalReferenceService, loggerFactory, xmiReader, currentLocation); + return readerFactory(xmiDataCache, externalReferenceService, loggerFactory, xmiReader, currentLocation, elementOriginMap); } - + throw new InvalidOperationException($"No reader found for xsi:type - {xsiType}"); } diff --git a/SysML2.NET.CodeGenerator/Templates/Uml/core-xmi-reader-template.hbs b/SysML2.NET.CodeGenerator/Templates/Uml/core-xmi-reader-template.hbs index 6105b3556..939f15a45 100644 --- a/SysML2.NET.CodeGenerator/Templates/Uml/core-xmi-reader-template.hbs +++ b/SysML2.NET.CodeGenerator/Templates/Uml/core-xmi-reader-template.hbs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; {{ #Class.WriteEnumerationNameSpaces this}} {{ #Class.WriteNameSpaces this POCO}} using SysML2.NET.Core.POCO.{{ #NamedElement.WriteFullyQualifiedNameSpace this }}; @@ -61,7 +62,8 @@ namespace SysML2.NET.Serializer.Xmi.Readers /// /// The injected used to register and process external references /// The injected used to set up logging - public {{this.Name}}Reader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public {{this.Name}}Reader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger<{{this.Name}}Reader>.Instance : loggerFactory.CreateLogger<{{this.Name}}Reader>(); } @@ -107,6 +109,8 @@ namespace SysML2.NET.Serializer.Xmi.Readers this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "{{this.Name}}", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + {{#with this as |class| }} {{ #each (Class.QueryAllProperties this) as | property | }} {{#unless this.IsTransient}} @@ -139,6 +143,10 @@ namespace SysML2.NET.Serializer.Xmi.Readers {{/unless}} {{/each}} {{/with}} + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading {{this.Name}} at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -187,6 +195,8 @@ namespace SysML2.NET.Serializer.Xmi.Readers { this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "{{this.Name}}", poco.Id); } + + this.ElementOriginMap?.Register(poco.Id, currentLocation); {{#with this as |class| }} {{ #each (Class.QueryAllProperties this) as | property | }} @@ -220,6 +230,10 @@ namespace SysML2.NET.Serializer.Xmi.Readers {{/unless}} {{/each}} {{/with}} + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading {{this.Name}} at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.CodeGenerator/Templates/Uml/core-xmi-writer-facade-template.hbs b/SysML2.NET.CodeGenerator/Templates/Uml/core-xmi-writer-facade-template.hbs new file mode 100644 index 000000000..2af934c41 --- /dev/null +++ b/SysML2.NET.CodeGenerator/Templates/Uml/core-xmi-writer-facade-template.hbs @@ -0,0 +1,288 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Elements; + + /// + /// The purpose of the is to dispatch writing of instances + /// to the appropriate per-type writer class + /// + public class XmiDataWriterFacade : IXmiDataWriterFacade + { + /// + /// A dictionary that contains actions that write based on a key that represents the POCO type name + /// + private readonly Dictionary> writerCache; + + /// + /// A dictionary that contains functions that asynchronously write based on a key that represents the POCO type name + /// + private readonly Dictionary> writerAsyncCache; + + /// + /// Initializes a new instance of the + /// + /// The used to set up logging + public XmiDataWriterFacade(ILoggerFactory loggerFactory) + { + {{ #each this as | class | }} + var {{ String.LowerCaseFirstLetter class.Name }}Writer = new {{ class.Name }}Writer(this, loggerFactory); + {{/each}} + + this.writerCache = new Dictionary> + { + {{ #each this as | class | }} + ["{{ class.Name }}"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + {{ String.LowerCaseFirstLetter class.Name }}Writer.Write(xmlWriter, (Core.POCO.{{ #NamedElement.WriteFullyQualifiedNameSpace class }}.I{{ class.Name }})data, elementName, writerOptions, originMap, uri); + }, + {{/each}} + }; + + this.writerAsyncCache = new Dictionary> + { + {{ #each this as | class | }} + ["{{ class.Name }}"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await {{ String.LowerCaseFirstLetter class.Name }}Writer.WriteAsync(xmlWriter, (Core.POCO.{{ #NamedElement.WriteFullyQualifiedNameSpace class }}.I{{ class.Name }})data, elementName, writerOptions, originMap, uri); + }, + {{/each}} + }; + } + + /// + /// Writes the specified as an XMI element by dispatching to the appropriate per-type writer + /// + /// The target + /// The to write + /// The XML element name to use + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The of the current output file for relative href computation + public void Write(XmlWriter xmlWriter, IData data, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + var typeName = data.GetType().Name; + + if (this.writerCache.TryGetValue(typeName, out var writer)) + { + writer(xmlWriter, data, elementName, writerOptions, elementOriginMap, currentFileUri); + } + else + { + throw new InvalidOperationException($"No writer found for type {typeName}"); + } + } + + /// + /// Writes a contained child element, checking origin map for cross-file href + /// + /// The target + /// The child to write + /// The XML element name to use + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The of the current output file for relative href computation + /// Asserts that the XSI type should be specified in case of HREF + public void WriteContainedElement(XmlWriter xmlWriter, IData childData, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, bool shouldSpecifyType = false) + { + if (!writerOptions.IncludeImplied && childData is IRelationship rel && rel.IsImplied) + { + return; + } + + if (elementOriginMap != null && currentFileUri != null) + { + var childSourceFile = elementOriginMap.GetSourceFile(childData.Id); + + if (childSourceFile != null && childSourceFile != currentFileUri) + { + WriteHrefElement(xmlWriter, childData, elementName, childSourceFile, currentFileUri, shouldSpecifyType); + return; + } + } + + this.Write(xmlWriter, childData, elementName, writerOptions, elementOriginMap, currentFileUri); + } + + /// + /// Writes a reference child element, checking origin map for cross-file href + /// + /// The target + /// The child to write + /// The XML element name to use + /// The optional for href reconstruction + /// The of the current output file for relative href computation + /// Asserts that the XSI type should be specified in case of HREF + public void WriteReferenceElement(XmlWriter xmlWriter, IData childData, string elementName, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, bool shouldSpecifyType = false) + { + if (elementOriginMap != null && currentFileUri != null) + { + var childSourceFile = elementOriginMap.GetSourceFile(childData.Id); + + if (childSourceFile != null && childSourceFile != currentFileUri) + { + WriteHrefElement(xmlWriter, childData, elementName, childSourceFile, currentFileUri, shouldSpecifyType); + return; + } + } + + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xmi", "idref", null, childData.Id.ToString()); + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the specified as an XMI element by dispatching to the appropriate per-type writer + /// + /// The target + /// The to write + /// The XML element name to use + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The of the current output file for relative href computation + public async Task WriteAsync(XmlWriter xmlWriter, IData data, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + var typeName = data.GetType().Name; + + if (this.writerAsyncCache.TryGetValue(typeName, out var writer)) + { + await writer(xmlWriter, data, elementName, writerOptions, elementOriginMap, currentFileUri); + } + else + { + throw new InvalidOperationException($"No writer found for type {typeName}"); + } + } + + /// + /// Asynchronously writes a contained child element, checking origin map for cross-file href + /// + /// The target + /// The child to write + /// The XML element name to use + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The of the current output file for relative href computation + /// Asserts that the XSI type should be specified in case of HREF + public async Task WriteContainedElementAsync(XmlWriter xmlWriter, IData childData, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, bool shouldSpecifyType = false) + { + if (!writerOptions.IncludeImplied && childData is IRelationship rel && rel.IsImplied) + { + return; + } + + if (elementOriginMap != null && currentFileUri != null) + { + var childSourceFile = elementOriginMap.GetSourceFile(childData.Id); + + if (childSourceFile != null && childSourceFile != currentFileUri) + { + await WriteHrefElementAsync(xmlWriter, childData, elementName, childSourceFile, currentFileUri, shouldSpecifyType); + return; + } + } + + await this.WriteAsync(xmlWriter, childData, elementName, writerOptions, elementOriginMap, currentFileUri); + } + + /// + /// Asynchronously writes a reference child element, checking origin map for cross-file href + /// + /// The target + /// The child to write + /// The XML element name to use + /// The optional for href reconstruction + /// The of the current output file for relative href computation + /// Asserts that the XSI type should be specified in case of HREF + public async Task WriteReferenceElementAsync(XmlWriter xmlWriter, IData childData, string elementName, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, bool shouldSpecifyType = false) + { + if (elementOriginMap != null && currentFileUri != null) + { + var childSourceFile = elementOriginMap.GetSourceFile(childData.Id); + + if (childSourceFile != null && childSourceFile != currentFileUri) + { + await WriteHrefElementAsync(xmlWriter, childData, elementName, childSourceFile, currentFileUri, shouldSpecifyType); + return; + } + } + + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xmi", "idref", null, childData.Id.ToString()); + await xmlWriter.WriteEndElementAsync(); + } + + /// + /// Writes an href element for cross-file references + /// + private static void WriteHrefElement(XmlWriter xmlWriter, IData childData, string elementName, Uri targetFile, Uri currentFile, bool shouldSpecifyType) + { + var relativePath = currentFile.MakeRelativeUri(targetFile); + var href = $"{Uri.UnescapeDataString(relativePath.ToString())}#{childData.Id}"; + + xmlWriter.WriteStartElement(elementName); + + if(shouldSpecifyType) + { + xmlWriter.WriteAttributeString("xsi", "type", null, $"sysml:{childData.GetType().Name}"); + } + + xmlWriter.WriteAttributeString("href", href); + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes an href element for cross-file references + /// + private static async Task WriteHrefElementAsync(XmlWriter xmlWriter, IData childData, string elementName, Uri targetFile, Uri currentFile, bool shouldSpecifyType) + { + var relativePath = currentFile.MakeRelativeUri(targetFile); + var href = $"{Uri.UnescapeDataString(relativePath.ToString())}#{childData.Id}"; + + await xmlWriter.WriteStartElementAsync(null, elementName, null); + + if(shouldSpecifyType) + { + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, $"sysml:{childData.GetType().Name}"); + } + + await xmlWriter.WriteAttributeStringAsync(null, "href", null, href); + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.CodeGenerator/Templates/Uml/core-xmi-writer-template.hbs b/SysML2.NET.CodeGenerator/Templates/Uml/core-xmi-writer-template.hbs new file mode 100644 index 000000000..0bc18d3ac --- /dev/null +++ b/SysML2.NET.CodeGenerator/Templates/Uml/core-xmi-writer-template.hbs @@ -0,0 +1,199 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + {{ #Class.WriteEnumerationNameSpaces this}} + {{ #Class.WriteNameSpaces this POCO}} + using SysML2.NET.Core.POCO.{{ #NamedElement.WriteFullyQualifiedNameSpace this }}; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class {{this.Name}}Writer : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger<{{this.Name}}Writer> logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public {{this.Name}}Writer(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger<{{this.Name}}Writer>.Instance : loggerFactory.CreateLogger<{{this.Name}}Writer>(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, I{{this.Name}} poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:{{this.Name}}"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + {{#with this as |class| }} + {{ #each (Class.QueryAllPropertiesSorted this) as | property | }} + {{#unless this.IsTransient}} + {{#unless (Property.QueryIsEnumerableAndReferenceProperty this)}} + {{#unless (Property.IsPropertyRedefinedInClass this class)}} + {{#unless property.Opposite.IsComposite}} + {{#if this.IsDerived}} + if(writerOptions.IncludeDerivedProperties) + { + {{> core-xmi-writer-partial-for-attribute-template this}} + } + {{else}} + {{> core-xmi-writer-partial-for-attribute-template this}} + {{/if}} + + {{/unless}} + {{/unless}} + {{/unless}} + {{/unless}} + {{/each}} + {{/with}} + + // Reference/containment properties as child elements (sorted alphabetically) + {{#with this as |class| }} + {{ #each (Class.QueryAllPropertiesSorted this) as | property | }} + {{#unless this.IsTransient}} + {{#if (Property.QueryIsReferenceProperty this)}} + {{#unless (Property.IsPropertyRedefinedInClass this class)}} + {{#unless property.Opposite.IsComposite}} + {{#if this.IsDerived}} + if(writerOptions.IncludeDerivedProperties) + { + {{> core-xmi-writer-partial-for-element-template this}} + } + {{else}} + {{> core-xmi-writer-partial-for-element-template this}} + {{/if}} + + {{/unless}} + {{/unless}} + {{/if}} + {{/unless}} + {{/each}} + {{/with}} + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, I{{this.Name}} poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:{{this.Name}}"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + {{#with this as |class| }} + {{ #each (Class.QueryAllPropertiesSorted this) as | property | }} + {{#unless this.IsTransient}} + {{#unless (Property.QueryIsEnumerableAndReferenceProperty this)}} + {{#unless (Property.IsPropertyRedefinedInClass this class)}} + {{#unless property.Opposite.IsComposite}} + {{#if this.IsDerived}} + if(writerOptions.IncludeDerivedProperties) + { + {{> core-xmi-writer-partial-for-attribute-async-template this}} + } + {{else}} + {{> core-xmi-writer-partial-for-attribute-async-template this}} + {{/if}} + + {{/unless}} + {{/unless}} + {{/unless}} + {{/unless}} + {{/each}} + {{/with}} + + // Reference/containment properties as child elements (sorted alphabetically) + {{#with this as |class| }} + {{ #each (Class.QueryAllPropertiesSorted this) as | property | }} + {{#unless this.IsTransient}} + {{#if (Property.QueryIsReferenceProperty this)}} + {{#unless property.Opposite.IsComposite}} + {{#unless (Property.IsPropertyRedefinedInClass this class)}} + {{#if this.IsDerived}} + if(writerOptions.IncludeDerivedProperties) + { + {{> core-xmi-writer-partial-for-element-async-template this}} + } + {{else}} + {{> core-xmi-writer-partial-for-element-async-template this}} + {{/if}} + + {{/unless}} + {{/unless}} + {{/if}} + {{/unless}} + {{/each}} + {{/with}} + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Extensions.Tests/Core/EnumProvider/VisibilityKindProviderTestFixture.cs b/SysML2.NET.Extensions.Tests/Core/EnumProvider/VisibilityKindProviderTestFixture.cs index 3da28463a..fba181686 100644 --- a/SysML2.NET.Extensions.Tests/Core/EnumProvider/VisibilityKindProviderTestFixture.cs +++ b/SysML2.NET.Extensions.Tests/Core/EnumProvider/VisibilityKindProviderTestFixture.cs @@ -48,6 +48,29 @@ public void Verify_that_enumvalue_throws_exception_from_unknown_string() Assert.That(() => VisibilityKindProvider.Parse("Starion"), Throws.ArgumentException); } + [Test] + [TestCase("Private", VisibilityKind.Private)] + [TestCase("Protected", VisibilityKind.Protected)] + [TestCase("Public", VisibilityKind.Public)] + [TestCase("private", VisibilityKind.Private)] + [TestCase("protected", VisibilityKind.Protected)] + [TestCase("public", VisibilityKind.Public)] + public void Verify_that_TryParse_returns_true_for_valid_value(string input, VisibilityKind expected) + { + Assert.That(VisibilityKindProvider.TryParse(input.AsSpan(), out var result), Is.True); + Assert.That(result, Is.EqualTo(expected)); + } + + [Test] + [TestCase("Starion")] + [TestCase("")] + [TestCase("internal")] + public void Verify_that_TryParse_returns_false_for_invalid_value(string input) + { + Assert.That(VisibilityKindProvider.TryParse(input.AsSpan(), out var result), Is.False); + Assert.That(result, Is.EqualTo(default(VisibilityKind))); + } + [Test] [TestCase("private", VisibilityKind.Private)] [TestCase("protected", VisibilityKind.Protected)] diff --git a/SysML2.NET.Extensions/Core/AutoGenEnumProvider/FeatureDirectionKindProvider.cs b/SysML2.NET.Extensions/Core/AutoGenEnumProvider/FeatureDirectionKindProvider.cs index bf47ec02e..c4efd0c5f 100644 --- a/SysML2.NET.Extensions/Core/AutoGenEnumProvider/FeatureDirectionKindProvider.cs +++ b/SysML2.NET.Extensions/Core/AutoGenEnumProvider/FeatureDirectionKindProvider.cs @@ -73,6 +73,48 @@ public static FeatureDirectionKind Parse(ReadOnlySpan value) throw new ArgumentException($"'{new string(value)}' is not a valid FeatureDirectionKind", nameof(value)); } + /// + /// Tries to parse the to a + /// + /// + /// The that is to be parsed + /// + /// + /// When this method returns, contains the value equivalent + /// to the span, if the conversion succeeded, or default if the conversion failed. + /// + /// + /// true if was converted successfully; otherwise, false. + /// + /// + /// This method is suited for string parsing + /// There are zero allocations, no boxing, Fast short-circuit evaluation + /// JIT friendly + /// + public static bool TryParse(ReadOnlySpan value, out FeatureDirectionKind result) + { + if (value.Length == 2 && value.Equals("in".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = FeatureDirectionKind.In; + return true; + } + + if (value.Length == 5 && value.Equals("inout".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = FeatureDirectionKind.Inout; + return true; + } + + if (value.Length == 3 && value.Equals("out".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = FeatureDirectionKind.Out; + return true; + } + + result = default; + return false; + } + /// /// Parses the to a /// diff --git a/SysML2.NET.Extensions/Core/AutoGenEnumProvider/PortionKindProvider.cs b/SysML2.NET.Extensions/Core/AutoGenEnumProvider/PortionKindProvider.cs index ce09d45fb..f3d94dd02 100644 --- a/SysML2.NET.Extensions/Core/AutoGenEnumProvider/PortionKindProvider.cs +++ b/SysML2.NET.Extensions/Core/AutoGenEnumProvider/PortionKindProvider.cs @@ -68,6 +68,42 @@ public static PortionKind Parse(ReadOnlySpan value) throw new ArgumentException($"'{new string(value)}' is not a valid PortionKind", nameof(value)); } + /// + /// Tries to parse the to a + /// + /// + /// The that is to be parsed + /// + /// + /// When this method returns, contains the value equivalent + /// to the span, if the conversion succeeded, or default if the conversion failed. + /// + /// + /// true if was converted successfully; otherwise, false. + /// + /// + /// This method is suited for string parsing + /// There are zero allocations, no boxing, Fast short-circuit evaluation + /// JIT friendly + /// + public static bool TryParse(ReadOnlySpan value, out PortionKind result) + { + if (value.Length == 9 && value.Equals("timeslice".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = PortionKind.Timeslice; + return true; + } + + if (value.Length == 8 && value.Equals("snapshot".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = PortionKind.Snapshot; + return true; + } + + result = default; + return false; + } + /// /// Parses the to a /// diff --git a/SysML2.NET.Extensions/Core/AutoGenEnumProvider/RequirementConstraintKindProvider.cs b/SysML2.NET.Extensions/Core/AutoGenEnumProvider/RequirementConstraintKindProvider.cs index 3fbf53825..041c24322 100644 --- a/SysML2.NET.Extensions/Core/AutoGenEnumProvider/RequirementConstraintKindProvider.cs +++ b/SysML2.NET.Extensions/Core/AutoGenEnumProvider/RequirementConstraintKindProvider.cs @@ -68,6 +68,42 @@ public static RequirementConstraintKind Parse(ReadOnlySpan value) throw new ArgumentException($"'{new string(value)}' is not a valid RequirementConstraintKind", nameof(value)); } + /// + /// Tries to parse the to a + /// + /// + /// The that is to be parsed + /// + /// + /// When this method returns, contains the value equivalent + /// to the span, if the conversion succeeded, or default if the conversion failed. + /// + /// + /// true if was converted successfully; otherwise, false. + /// + /// + /// This method is suited for string parsing + /// There are zero allocations, no boxing, Fast short-circuit evaluation + /// JIT friendly + /// + public static bool TryParse(ReadOnlySpan value, out RequirementConstraintKind result) + { + if (value.Length == 10 && value.Equals("assumption".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = RequirementConstraintKind.Assumption; + return true; + } + + if (value.Length == 11 && value.Equals("requirement".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = RequirementConstraintKind.Requirement; + return true; + } + + result = default; + return false; + } + /// /// Parses the to a /// diff --git a/SysML2.NET.Extensions/Core/AutoGenEnumProvider/StateSubactionKindProvider.cs b/SysML2.NET.Extensions/Core/AutoGenEnumProvider/StateSubactionKindProvider.cs index d40fbf511..f392c1a1a 100644 --- a/SysML2.NET.Extensions/Core/AutoGenEnumProvider/StateSubactionKindProvider.cs +++ b/SysML2.NET.Extensions/Core/AutoGenEnumProvider/StateSubactionKindProvider.cs @@ -73,6 +73,48 @@ public static StateSubactionKind Parse(ReadOnlySpan value) throw new ArgumentException($"'{new string(value)}' is not a valid StateSubactionKind", nameof(value)); } + /// + /// Tries to parse the to a + /// + /// + /// The that is to be parsed + /// + /// + /// When this method returns, contains the value equivalent + /// to the span, if the conversion succeeded, or default if the conversion failed. + /// + /// + /// true if was converted successfully; otherwise, false. + /// + /// + /// This method is suited for string parsing + /// There are zero allocations, no boxing, Fast short-circuit evaluation + /// JIT friendly + /// + public static bool TryParse(ReadOnlySpan value, out StateSubactionKind result) + { + if (value.Length == 5 && value.Equals("entry".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = StateSubactionKind.Entry; + return true; + } + + if (value.Length == 2 && value.Equals("do".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = StateSubactionKind.Do; + return true; + } + + if (value.Length == 4 && value.Equals("exit".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = StateSubactionKind.Exit; + return true; + } + + result = default; + return false; + } + /// /// Parses the to a /// diff --git a/SysML2.NET.Extensions/Core/AutoGenEnumProvider/TransitionFeatureKindProvider.cs b/SysML2.NET.Extensions/Core/AutoGenEnumProvider/TransitionFeatureKindProvider.cs index f5ffa038f..218d1be57 100644 --- a/SysML2.NET.Extensions/Core/AutoGenEnumProvider/TransitionFeatureKindProvider.cs +++ b/SysML2.NET.Extensions/Core/AutoGenEnumProvider/TransitionFeatureKindProvider.cs @@ -73,6 +73,48 @@ public static TransitionFeatureKind Parse(ReadOnlySpan value) throw new ArgumentException($"'{new string(value)}' is not a valid TransitionFeatureKind", nameof(value)); } + /// + /// Tries to parse the to a + /// + /// + /// The that is to be parsed + /// + /// + /// When this method returns, contains the value equivalent + /// to the span, if the conversion succeeded, or default if the conversion failed. + /// + /// + /// true if was converted successfully; otherwise, false. + /// + /// + /// This method is suited for string parsing + /// There are zero allocations, no boxing, Fast short-circuit evaluation + /// JIT friendly + /// + public static bool TryParse(ReadOnlySpan value, out TransitionFeatureKind result) + { + if (value.Length == 7 && value.Equals("trigger".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = TransitionFeatureKind.Trigger; + return true; + } + + if (value.Length == 5 && value.Equals("guard".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = TransitionFeatureKind.Guard; + return true; + } + + if (value.Length == 6 && value.Equals("effect".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = TransitionFeatureKind.Effect; + return true; + } + + result = default; + return false; + } + /// /// Parses the to a /// diff --git a/SysML2.NET.Extensions/Core/AutoGenEnumProvider/TriggerKindProvider.cs b/SysML2.NET.Extensions/Core/AutoGenEnumProvider/TriggerKindProvider.cs index 4bfda599f..db83aa8d8 100644 --- a/SysML2.NET.Extensions/Core/AutoGenEnumProvider/TriggerKindProvider.cs +++ b/SysML2.NET.Extensions/Core/AutoGenEnumProvider/TriggerKindProvider.cs @@ -73,6 +73,48 @@ public static TriggerKind Parse(ReadOnlySpan value) throw new ArgumentException($"'{new string(value)}' is not a valid TriggerKind", nameof(value)); } + /// + /// Tries to parse the to a + /// + /// + /// The that is to be parsed + /// + /// + /// When this method returns, contains the value equivalent + /// to the span, if the conversion succeeded, or default if the conversion failed. + /// + /// + /// true if was converted successfully; otherwise, false. + /// + /// + /// This method is suited for string parsing + /// There are zero allocations, no boxing, Fast short-circuit evaluation + /// JIT friendly + /// + public static bool TryParse(ReadOnlySpan value, out TriggerKind result) + { + if (value.Length == 4 && value.Equals("when".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = TriggerKind.When; + return true; + } + + if (value.Length == 2 && value.Equals("at".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = TriggerKind.At; + return true; + } + + if (value.Length == 5 && value.Equals("after".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = TriggerKind.After; + return true; + } + + result = default; + return false; + } + /// /// Parses the to a /// diff --git a/SysML2.NET.Extensions/Core/AutoGenEnumProvider/VisibilityKindProvider.cs b/SysML2.NET.Extensions/Core/AutoGenEnumProvider/VisibilityKindProvider.cs index 9868846be..82ee5af4b 100644 --- a/SysML2.NET.Extensions/Core/AutoGenEnumProvider/VisibilityKindProvider.cs +++ b/SysML2.NET.Extensions/Core/AutoGenEnumProvider/VisibilityKindProvider.cs @@ -73,6 +73,48 @@ public static VisibilityKind Parse(ReadOnlySpan value) throw new ArgumentException($"'{new string(value)}' is not a valid VisibilityKind", nameof(value)); } + /// + /// Tries to parse the to a + /// + /// + /// The that is to be parsed + /// + /// + /// When this method returns, contains the value equivalent + /// to the span, if the conversion succeeded, or default if the conversion failed. + /// + /// + /// true if was converted successfully; otherwise, false. + /// + /// + /// This method is suited for string parsing + /// There are zero allocations, no boxing, Fast short-circuit evaluation + /// JIT friendly + /// + public static bool TryParse(ReadOnlySpan value, out VisibilityKind result) + { + if (value.Length == 7 && value.Equals("private".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = VisibilityKind.Private; + return true; + } + + if (value.Length == 9 && value.Equals("protected".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = VisibilityKind.Protected; + return true; + } + + if (value.Length == 6 && value.Equals("public".AsSpan(), StringComparison.OrdinalIgnoreCase)) + { + result = VisibilityKind.Public; + return true; + } + + result = default; + return false; + } + /// /// Parses the to a /// diff --git a/SysML2.NET.Serializer.Xmi.Tests/DeSerializerTestFixture.cs b/SysML2.NET.Serializer.Xmi.Tests/DeSerializerTestFixture.cs index b238c8675..39dc082a1 100644 --- a/SysML2.NET.Serializer.Xmi.Tests/DeSerializerTestFixture.cs +++ b/SysML2.NET.Serializer.Xmi.Tests/DeSerializerTestFixture.cs @@ -29,13 +29,11 @@ namespace SysML2.NET.Serializer.Xmi.Tests using Microsoft.Extensions.Logging; using SysML2.NET.Serializer.Xmi.Extensions; - using SysML2.NET.Serializer.Xmi.Readers; [TestFixture] public class DeSerializerTestFixture { private DeSerializer deSerializer; - private XmiDataCache xmiDataCache; [SetUp] public void Setup() @@ -44,9 +42,7 @@ public void Setup() .AddLogging(x => x.AddConsole()) .BuildServiceProvider(); - this.xmiDataCache = new XmiDataCache(new PocoReferenceResolveExtensionsFacade(),serviceProvider.GetRequiredService>()); - - this.deSerializer = new DeSerializer(new ExternalReferenceService(serviceProvider.GetRequiredService>()), new XmiDataReaderFacade(), this.xmiDataCache, serviceProvider.GetRequiredService()); + this.deSerializer = new DeSerializer(serviceProvider.GetRequiredService()); } [Test] diff --git a/SysML2.NET.Serializer.Xmi.Tests/RoundTripTestFixture.cs b/SysML2.NET.Serializer.Xmi.Tests/RoundTripTestFixture.cs new file mode 100644 index 000000000..879c63cc7 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi.Tests/RoundTripTestFixture.cs @@ -0,0 +1,297 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Tests +{ + using System; + using System.IO; + using System.Linq; + using System.Threading; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.Logging; + + using Org.XmlUnit.Builder; + using Org.XmlUnit.Diff; + + using SysML2.NET.Serializer.Xmi.Writers; + + [TestFixture] + public class RoundTripTestFixture + { + private ILoggerFactory loggerFactory; + + private XmiWriterOptions writerOptions = new(); + + [SetUp] + public void Setup() + { + var serviceProvider = new ServiceCollection() + .AddLogging(x => x.AddConsole()) + .BuildServiceProvider(); + + this.loggerFactory = serviceProvider.GetRequiredService(); + } + + [Test] + public void Verify_that_deserialization_with_origin_map_tracks_elements() + { + var deSerializer = new DeSerializer(this.loggerFactory); + + var originMap = new XmiElementOriginMap(); + + var filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "Resources", "Domain Libraries", "Quantities and Units", "Quantities.sysmlx"); + var fileUri = new Uri(filePath); + + var rootNamespace = deSerializer.DeSerialize(fileUri, originMap); + + Assert.That(rootNamespace, Is.Not.Null); + + // Verify that elements were tracked + var allSourceFiles = originMap.GetAllSourceFiles().ToList(); + Assert.That(allSourceFiles, Is.Not.Empty); + + // Verify that the root namespace was registered + var rootNsId = originMap.GetRootNamespaceId(fileUri); + Assert.That(rootNsId, Is.EqualTo(rootNamespace.Id)); + + // Verify that elements in the file can be queried + var elementsInFile = originMap.GetElementsInFile(fileUri).ToList(); + Assert.That(elementsInFile, Is.Not.Empty); + Assert.That(elementsInFile, Does.Contain(rootNamespace.Id)); + } + + [Test] + public void Verify_that_serialized_output_is_well_formed_xml_with_correct_root() + { + // Step 1: Deserialize original + var deSerializer1 = new DeSerializer(this.loggerFactory); + + var filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "Resources", "Domain Libraries", "Quantities and Units", "Quantities.sysmlx"); + var originalNamespace = deSerializer1.DeSerialize(new Uri(filePath)); + + Assert.That(originalNamespace, Is.Not.Null); + + // Step 2: Serialize to stream + var serializer = new Serializer(this.loggerFactory); + var memoryStream = new MemoryStream(); + + serializer.Serialize(originalNamespace, this.writerOptions, memoryStream); + + Assert.That(memoryStream.Length, Is.GreaterThan(0)); + + // Step 3: Verify the output is well-formed XML with correct structure + memoryStream.Seek(0, SeekOrigin.Begin); + + var xmlDoc = new System.Xml.XmlDocument(); + Assert.That(() => xmlDoc.Load(memoryStream), Throws.Nothing, "Output should be well-formed XML"); + + var rootElement = xmlDoc.DocumentElement; + Assert.That(rootElement, Is.Not.Null); + Assert.That(rootElement.LocalName, Is.EqualTo("Namespace")); + Assert.That(rootElement.GetAttribute("id", "http://www.omg.org/spec/XMI/20131001"), Is.EqualTo(originalNamespace.Id.ToString())); + + // Verify there are child elements (ownedRelationship) + var childElements = rootElement.ChildNodes.Cast().Where(n => n.NodeType == System.Xml.XmlNodeType.Element).ToList(); + Assert.That(childElements, Is.Not.Empty, "Should have child elements"); + } + + [Test] + public void Verify_that_origin_map_captures_multi_file_references() + { + var deSerializer = new DeSerializer(this.loggerFactory); + + var originMap = new XmiElementOriginMap(); + + // Quantities.sysmlx references other files like ScalarValues.kermlx, ISQBase.sysmlx, etc. + var filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "Resources", "Domain Libraries", "Quantities and Units", "Quantities.sysmlx"); + var fileUri = new Uri(filePath); + + deSerializer.DeSerialize(fileUri, originMap); + + var allSourceFiles = originMap.GetAllSourceFiles().ToList(); + + // Should have multiple source files since Quantities.sysmlx has external references + Assert.That(allSourceFiles.Count, Is.GreaterThan(1)); + + // Each source file should have a root namespace registered + foreach (var sourceFile in allSourceFiles) + { + var rootNsId = originMap.GetRootNamespaceId(sourceFile); + Assert.That(rootNsId, Is.Not.EqualTo(Guid.Empty), $"Root namespace not registered for {sourceFile}"); + } + } + + [Test] + public void VerifySerializedXmlCorrespondToOriginalFile() + { + var deSerializer = new DeSerializer(this.loggerFactory); + + var originMap = new XmiElementOriginMap(); + + // Quantities.sysmlx references other files like ScalarValues.kermlx, ISQBase.sysmlx, etc. + var filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "Resources", "Domain Libraries", "Quantities and Units", "Quantities.sysmlx"); + var fileUri = new Uri(filePath); + + var quantityNamespace = deSerializer.DeSerialize(fileUri, originMap); + + var serializer = new Serializer(this.loggerFactory); + var outputFile = Path.Combine(TestContext.CurrentContext.TestDirectory, "SerializedQuantities.sysmlx"); + + var fileStream = new FileStream(outputFile, FileMode.Create); + + serializer.Serialize(quantityNamespace, this.writerOptions, fileStream, originMap, new Uri(filePath)); + fileStream.Close(); + + var content = File.ReadAllText(outputFile); + + var xmlDiff = DiffBuilder.Compare(Input.FromFile(filePath)) + .WithTest(Input.FromString(content.Replace("http://www.omg.org/spec/XMI/20131001", "http://www.omg.org/XMI"))) + .IgnoreWhitespace() + .IgnoreComments() + .WithAttributeFilter(attr => attr.LocalName != "version") + .WithDifferenceEvaluator((comparison, outcome) => + { + switch (comparison.Type) + { + case ComparisonType.XML_ENCODING: + case ComparisonType.XML_VERSION: + return ComparisonResult.EQUAL; + case ComparisonType.ATTR_VALUE: + { + var control = comparison.ControlDetails.Value?.ToString()?.Replace("%20", " "); + var test = comparison.TestDetails.Value?.ToString()?.Replace("%20", " "); + + if (control == test) + { + return ComparisonResult.EQUAL; + } + + break; + } + + case ComparisonType.ATTR_NAME_LOOKUP: + { + if (outcome != ComparisonResult.EQUAL && comparison.ControlDetails.Target is XmlElement controlElement) + { + var testElement = (XmlElement)comparison.TestDetails.Target; + + if (controlElement.HasAttribute("isComposite") && !testElement.HasAttribute("isComposite")) + { + return controlElement.GetAttribute("isComposite") == "false" ? ComparisonResult.EQUAL : ComparisonResult.DIFFERENT; + } + + if (controlElement.HasAttribute("declaredName") && !testElement.HasAttribute("declaredName")) + { + return controlElement.GetAttribute("declaredName") == "" ? ComparisonResult.EQUAL : ComparisonResult.DIFFERENT; + } + } + + break; + } + + case ComparisonType.ELEMENT_NUM_ATTRIBUTES: + { + var controlCount = Convert.ToInt32(comparison.ControlDetails.Value); + var testCount = Convert.ToInt32(comparison.TestDetails.Value); + + if (Math.Abs(controlCount - testCount) == 1) + { + var controlElement =(XmlElement)comparison.ControlDetails.Target; + var testElement = (XmlElement)comparison.TestDetails.Target; + + if (controlElement.HasAttribute("isComposite") && !testElement.HasAttribute("isComposite")) + { + return controlElement.GetAttribute("isComposite") == "false" ? ComparisonResult.EQUAL : ComparisonResult.DIFFERENT; + } + + if (controlElement.HasAttribute("declaredName") && !testElement.HasAttribute("declaredName")) + { + return controlElement.GetAttribute("declaredName") == "" ? ComparisonResult.EQUAL : ComparisonResult.DIFFERENT; + } + } + + break; + } + } + + return outcome; + }) + .CheckForIdentical() + .Build(); + + Assert.That(xmlDiff.HasDifferences, Is.False); + } + + [Test] + public async Task Verify_that_multi_file_SerializeAsync_writes_expected_files() + { + var deSerializer = new DeSerializer(this.loggerFactory); + var originMap = new XmiElementOriginMap(); + + var filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "Resources", "Domain Libraries", "Quantities and Units", "Quantities.sysmlx"); + var fileUri = new Uri(filePath); + + var rootNamespace = await deSerializer.DeSerializeAsync(fileUri, originMap); + + var outputDirPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "AsyncMultiFileOutput"); + var outputDir = new DirectoryInfo(outputDirPath); + + try + { + var serializer = new Serializer(this.loggerFactory); + + await serializer.SerializeAsync(rootNamespace, originMap, outputDir, this.writerOptions, CancellationToken.None); + + Assert.That(outputDir.Exists, Is.True, "Output directory should exist"); + + var outputFiles = outputDir.GetFiles("*", SearchOption.AllDirectories); + Assert.That(outputFiles, Is.Not.Empty, "Output directory should contain files"); + + // The serializer only writes files for namespaces it can resolve from the deserialized graph. + // Referenced external files in the origin map may not have their namespaces available. + Assert.That(outputFiles.Length, Is.GreaterThanOrEqualTo(1), "At least the root namespace file should be written"); + Assert.That(outputFiles.Length, Is.LessThanOrEqualTo(originMap.GetAllSourceFiles().Count()), "Should not write more files than source files in origin map"); + + foreach (var outputFile in outputFiles) + { + Assert.That(outputFile.Length, Is.GreaterThan(0), $"File {outputFile.Name} should not be empty"); + + var xmlDoc = new XmlDocument(); + Assert.That(() => xmlDoc.Load(outputFile.FullName), Throws.Nothing, $"File {outputFile.Name} should be well-formed XML"); + + var rootElement = xmlDoc.DocumentElement; + Assert.That(rootElement, Is.Not.Null, $"File {outputFile.Name} should have a root element"); + Assert.That(rootElement.LocalName, Is.EqualTo("Namespace"), $"File {outputFile.Name} should have root element 'Namespace'"); + Assert.That(rootElement.GetAttribute("id", "http://www.omg.org/spec/XMI/20131001"), Is.Not.Empty, $"File {outputFile.Name} should have an xmi:id attribute"); + } + } + finally + { + if (Directory.Exists(outputDirPath)) + { + Directory.Delete(outputDirPath, true); + } + } + } + } +} diff --git a/SysML2.NET.Serializer.Xmi.Tests/SerializerArgumentValidationTestFixture.cs b/SysML2.NET.Serializer.Xmi.Tests/SerializerArgumentValidationTestFixture.cs new file mode 100644 index 000000000..1b6c7dd73 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi.Tests/SerializerArgumentValidationTestFixture.cs @@ -0,0 +1,326 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Tests +{ + using System; + using System.IO; + using System.Linq; + using System.Threading; + using System.Threading.Tasks; + + using Core.POCO.Root.Namespaces; + + using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.Logging; + + using SysML2.NET.Serializer.Xmi.Writers; + + [TestFixture] + public class SerializerArgumentValidationTestFixture + { + private Serializer serializer; + private DeSerializer deSerializer; + + private INamespace loadedNamespace; + private XmiWriterOptions writerOptions = new(); + + [SetUp] + public void Setup() + { + var serviceProvider = new ServiceCollection() + .AddLogging(x => x.AddConsole()) + .BuildServiceProvider(); + + this.deSerializer = new DeSerializer(serviceProvider.GetRequiredService()); + + var filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "Resources", "Domain Libraries", "Quantities and Units", "Quantities.sysmlx"); + this.loadedNamespace = this.deSerializer.DeSerialize(new Uri(filePath)); + + this.serializer = new Serializer(serviceProvider.GetRequiredService()); + } + + [Test] + public void Verify_that_Serialize_throws_ArgumentNullException_when_namespace_is_null() + { + var stream = new MemoryStream(); + + Assert.That(() => this.serializer.Serialize(null, this.writerOptions, stream), + Throws.TypeOf()); + } + + [Test] + public void Verify_that_Serialize_throws_ArgumentNullException_when_stream_is_null() + { + Assert.That(() => this.serializer.Serialize(this.loadedNamespace, this.writerOptions, null), + Throws.TypeOf()); + } + + [Test] + public void Verify_that_Serialize_with_origin_map_throws_ArgumentNullException_when_namespace_is_null() + { + var stream = new MemoryStream(); + var map = new XmiElementOriginMap(); + + Assert.That(() => this.serializer.Serialize(null, this.writerOptions, stream, map, new Uri("file:///test.sysmlx")), + Throws.TypeOf()); + } + + [Test] + public void Verify_that_Serialize_with_origin_map_throws_ArgumentNullException_when_stream_is_null() + { + var map = new XmiElementOriginMap(); + + Assert.That(() => this.serializer.Serialize(this.loadedNamespace, this.writerOptions, null, map, new Uri("file:///test.sysmlx")), + Throws.TypeOf()); + } + + [Test] + public void Verify_that_Serialize_with_origin_map_succeeds_when_elementOriginMap_is_null() + { + var stream = new MemoryStream(); + + Assert.That(() => this.serializer.Serialize(this.loadedNamespace, this.writerOptions, stream, null, new Uri("file:///test.sysmlx")), + Throws.Nothing); + } + + [Test] + public void Verify_that_Serialize_with_origin_map_succeeds_when_currentFileUri_is_null() + { + var stream = new MemoryStream(); + var map = new XmiElementOriginMap(); + + Assert.That(() => this.serializer.Serialize(this.loadedNamespace, this.writerOptions, stream, map, null), + Throws.Nothing); + } + + [Test] + public void Verify_that_multi_file_Serialize_throws_ArgumentNullException_when_rootNamespace_is_null() + { + var map = new XmiElementOriginMap(); + var outputDir = new DirectoryInfo(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); + + Assert.That(() => this.serializer.Serialize(null, map, outputDir, this.writerOptions), + Throws.TypeOf()); + } + + [Test] + public void Verify_that_multi_file_Serialize_throws_ArgumentNullException_when_elementOriginMap_is_null() + { + var outputDir = new DirectoryInfo(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); + + Assert.That(() => this.serializer.Serialize(this.loadedNamespace, null, outputDir, this.writerOptions), + Throws.TypeOf()); + } + + [Test] + public void Verify_that_multi_file_Serialize_throws_ArgumentNullException_when_outputDirectory_is_null() + { + var map = new XmiElementOriginMap(); + + Assert.That(() => this.serializer.Serialize(this.loadedNamespace, map, null, this.writerOptions), + Throws.TypeOf()); + } + + [Test] + public void Verify_that_SerializeAsync_throws_ArgumentNullException_when_namespace_is_null() + { + var stream = new MemoryStream(); + + Assert.That(async () => await this.serializer.SerializeAsync(null, this.writerOptions, stream, CancellationToken.None), + Throws.TypeOf()); + } + + [Test] + public void Verify_that_SerializeAsync_throws_ArgumentNullException_when_stream_is_null() + { + Assert.That(async () => await this.serializer.SerializeAsync(this.loadedNamespace, this.writerOptions, null, CancellationToken.None), + Throws.TypeOf()); + } + + [Test] + public void Verify_that_SerializeAsync_with_origin_map_throws_ArgumentNullException_when_namespace_is_null() + { + var stream = new MemoryStream(); + var map = new XmiElementOriginMap(); + + Assert.That(async () => await this.serializer.SerializeAsync(null, this.writerOptions, stream, map, new Uri("file:///test.sysmlx"), CancellationToken.None), + Throws.TypeOf()); + } + + [Test] + public void Verify_that_SerializeAsync_with_origin_map_throws_ArgumentNullException_when_stream_is_null() + { + var map = new XmiElementOriginMap(); + + Assert.That(async () => await this.serializer.SerializeAsync(this.loadedNamespace, this.writerOptions, null, map, new Uri("file:///test.sysmlx"), CancellationToken.None), + Throws.TypeOf()); + } + + [Test] + public void Verify_that_multi_file_SerializeAsync_throws_ArgumentNullException_when_rootNamespace_is_null() + { + var map = new XmiElementOriginMap(); + var outputDir = new DirectoryInfo(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); + + Assert.That(async () => await this.serializer.SerializeAsync(null, map, outputDir, this.writerOptions, CancellationToken.None), + Throws.TypeOf()); + } + + [Test] + public void Verify_that_multi_file_SerializeAsync_throws_ArgumentNullException_when_elementOriginMap_is_null() + { + var outputDir = new DirectoryInfo(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); + + Assert.That(async () => await this.serializer.SerializeAsync(this.loadedNamespace, null, outputDir, this.writerOptions, CancellationToken.None), + Throws.TypeOf()); + } + + [Test] + public void Verify_that_multi_file_SerializeAsync_throws_ArgumentNullException_when_outputDirectory_is_null() + { + var map = new XmiElementOriginMap(); + + Assert.That(async () => await this.serializer.SerializeAsync(this.loadedNamespace, map, null, this.writerOptions, CancellationToken.None), + Throws.TypeOf()); + } + + [Test] + public void Verify_that_multi_file_Serialize_creates_output_directory_if_not_exists() + { + var outputDir = new DirectoryInfo(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); + + try + { + Assert.That(outputDir.Exists, Is.False, "Output directory should not exist before serialization"); + + var map = new XmiElementOriginMap(); + var sourceUri = new Uri("file:///test/Quantities.sysmlx"); + + map.Register(this.loadedNamespace.Id, sourceUri); + map.RegisterRootNamespace(sourceUri, this.loadedNamespace.Id); + + this.serializer.Serialize(this.loadedNamespace, map, outputDir, this.writerOptions); + + outputDir.Refresh(); + Assert.That(outputDir.Exists, Is.True, "Output directory should be created by serialization"); + } + finally + { + if (outputDir.Exists) + { + outputDir.Delete(true); + } + } + } + + [Test] + public void Verify_that_multi_file_Serialize_skips_files_with_empty_root_namespace_id() + { + var outputDir = new DirectoryInfo(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); + + try + { + var map = new XmiElementOriginMap(); + var sourceUri = new Uri("file:///test/NoRoot.sysmlx"); + + // Register an element so GetAllSourceFiles returns this URI, + // but do NOT call RegisterRootNamespace so GetRootNamespaceId returns Guid.Empty + map.Register(Guid.NewGuid(), sourceUri); + + Assert.That(() => this.serializer.Serialize(this.loadedNamespace, map, outputDir, this.writerOptions), + Throws.Nothing); + + outputDir.Refresh(); + + if (outputDir.Exists) + { + var files = outputDir.GetFiles(); + Assert.That(files, Has.Length.EqualTo(0), "No files should be written when root namespace id is empty"); + } + } + finally + { + if (outputDir.Exists) + { + outputDir.Delete(true); + } + } + } + + [Test] + public void Verify_that_multi_file_Serialize_skips_files_with_unknown_namespace_id() + { + var outputDir = new DirectoryInfo(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); + + try + { + var map = new XmiElementOriginMap(); + var sourceUri = new Uri("file:///test/Unknown.sysmlx"); + var unknownNamespaceId = Guid.NewGuid(); + + // Register a source file with a root namespace id that does not exist in the loaded namespace tree + map.Register(Guid.NewGuid(), sourceUri); + map.RegisterRootNamespace(sourceUri, unknownNamespaceId); + + Assert.That(() => this.serializer.Serialize(this.loadedNamespace, map, outputDir, this.writerOptions), + Throws.Nothing); + + outputDir.Refresh(); + + if (outputDir.Exists) + { + var files = outputDir.GetFiles(); + Assert.That(files, Has.Length.EqualTo(0), "No files should be written when namespace id is not found in the namespace tree"); + } + } + finally + { + if (outputDir.Exists) + { + outputDir.Delete(true); + } + } + } + + [Test] + public void Verify_that_Serialize_writes_declaredName_attribute_when_set() + { + this.loadedNamespace.DeclaredName = "TestNamespaceName"; + + var stream = new MemoryStream(); + this.serializer.Serialize(this.loadedNamespace, this.writerOptions, stream); + + stream.Seek(0, SeekOrigin.Begin); + var content = new StreamReader(stream).ReadToEnd(); + + Assert.That(content, Does.Contain("declaredName=\"TestNamespaceName\"")); + } + + [Test] + public void Verify_that_Serialize_handles_null_writerOptions_by_defaulting() + { + var stream = new MemoryStream(); + + Assert.That(() => this.serializer.Serialize(this.loadedNamespace, null, stream), Throws.Nothing); + Assert.That(stream.Length, Is.GreaterThan(0)); + } + } +} diff --git a/SysML2.NET.Serializer.Xmi.Tests/SerializerTestFixture.cs b/SysML2.NET.Serializer.Xmi.Tests/SerializerTestFixture.cs new file mode 100644 index 000000000..63c2f4142 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi.Tests/SerializerTestFixture.cs @@ -0,0 +1,153 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Tests +{ + using System; + using System.IO; + using System.Linq; + using System.Threading; + using System.Threading.Tasks; + + using Core.POCO.Root.Namespaces; + + using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.Logging; + + using SysML2.NET.Serializer.Xmi.Writers; + + [TestFixture] + public class SerializerTestFixture + { + private Serializer serializer; + private DeSerializer deSerializer; + + private INamespace anonymouseNameSpace; + private XmiWriterOptions writerOptions = new(); + + [SetUp] + public void Setup() + { + var serviceProvider = new ServiceCollection() + .AddLogging(x => x.AddConsole()) + .BuildServiceProvider(); + + this.deSerializer = new DeSerializer(serviceProvider.GetRequiredService()); + + this.ReadAndAssemblePopulationFromXmiFile(); + + this.serializer = new Serializer(serviceProvider.GetRequiredService()); + } + + [Test] + public void Verify_that_the_name_space_can_be_serialized_to_xmi() + { + var targetStream = new MemoryStream(); + + Assert.That(() => this.serializer.Serialize(this.anonymouseNameSpace, this.writerOptions, targetStream), Throws.Nothing); + + Assert.That(targetStream.Length, Is.GreaterThan(0)); + } + + [Test] + public void Verify_that_serialized_xmi_contains_expected_structure() + { + var targetStream = new MemoryStream(); + + this.serializer.Serialize(this.anonymouseNameSpace, this.writerOptions, targetStream); + + targetStream.Seek(0, SeekOrigin.Begin); + var reader = new StreamReader(targetStream); + var content = reader.ReadToEnd(); + + Assert.That(content, Does.Contain("sysml:Namespace")); + Assert.That(content, Does.Contain("xmi:id=")); + Assert.That(content, Does.Contain("xmlns:xmi")); + Assert.That(content, Does.Contain("xmlns:xsi")); + } + + [Test] + public async Task Verify_that_the_name_space_can_be_serialized_to_xmi_async() + { + var targetStream = new MemoryStream(); + + await this.serializer.SerializeAsync(this.anonymouseNameSpace, this.writerOptions, targetStream, CancellationToken.None); + + Assert.That(targetStream.Length, Is.GreaterThan(0)); + } + + [Test] + public void Verify_that_includesImplied_false_excludes_implied_relationships() + { + var impliedRelationship = this.anonymouseNameSpace.OwnedRelationship.FirstOrDefault(); + Assert.That(impliedRelationship, Is.Not.Null, "Need at least one relationship to test"); + + impliedRelationship.IsImplied = true; + var impliedId = impliedRelationship.Id.ToString(); + + var targetStream = new MemoryStream(); + this.serializer.Serialize(this.anonymouseNameSpace, this.writerOptions, targetStream); + + targetStream.Seek(0, SeekOrigin.Begin); + var content = new StreamReader(targetStream).ReadToEnd(); + + Assert.That(content, Does.Not.Contain(impliedId), "Implied relationship should be excluded when includesImplied=false"); + Assert.That(content, Does.Not.Contain("isImpliedIncluded=\"true\""), "No element should have isImpliedIncluded=true when includesImplied=false"); + } + + [Test] + public void Verify_that_includesImplied_true_includes_implied_and_sets_isImpliedIncluded() + { + var impliedRelationship = this.anonymouseNameSpace.OwnedRelationship.FirstOrDefault(); + Assert.That(impliedRelationship, Is.Not.Null, "Need at least one relationship to test"); + + impliedRelationship.IsImplied = true; + impliedRelationship.IsImpliedIncluded = false; + + var targetStream = new MemoryStream(); + this.serializer.Serialize(this.anonymouseNameSpace, new XmiWriterOptions(){IncludeImplied = true}, targetStream); + + targetStream.Seek(0, SeekOrigin.Begin); + var content = new StreamReader(targetStream).ReadToEnd(); + + Assert.That(content, Does.Contain("isImpliedIncluded=\"true\""), "All elements should have isImpliedIncluded=true when includesImplied=true"); + } + + [Test] + public void Verify_that_includesImplied_false_uses_per_element_isImpliedIncluded() + { + this.anonymouseNameSpace.IsImpliedIncluded = true; + + var targetStream = new MemoryStream(); + this.serializer.Serialize(this.anonymouseNameSpace, this.writerOptions, targetStream); + + targetStream.Seek(0, SeekOrigin.Begin); + var content = new StreamReader(targetStream).ReadToEnd(); + + Assert.That(content, Does.Contain("isImpliedIncluded=\"true\""), "Root namespace with IsImpliedIncluded=true should appear in output"); + } + + private void ReadAndAssemblePopulationFromXmiFile() + { + var filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "Resources", "Domain Libraries", "Quantities and Units", "Quantities.sysmlx"); + this.anonymouseNameSpace = this.deSerializer.DeSerialize(new Uri(filePath)); + } + } +} diff --git a/SysML2.NET.Serializer.Xmi.Tests/SysML2.NET.Serializer.Xmi.Tests.csproj b/SysML2.NET.Serializer.Xmi.Tests/SysML2.NET.Serializer.Xmi.Tests.csproj index 0cbcab687..0fcda5077 100644 --- a/SysML2.NET.Serializer.Xmi.Tests/SysML2.NET.Serializer.Xmi.Tests.csproj +++ b/SysML2.NET.Serializer.Xmi.Tests/SysML2.NET.Serializer.Xmi.Tests.csproj @@ -32,6 +32,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/SysML2.NET.Serializer.Xmi.Tests/XmiElementOriginMapTestFixture.cs b/SysML2.NET.Serializer.Xmi.Tests/XmiElementOriginMapTestFixture.cs new file mode 100644 index 000000000..c56691569 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi.Tests/XmiElementOriginMapTestFixture.cs @@ -0,0 +1,126 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Tests +{ + using System; + using System.Linq; + + [TestFixture] + public class XmiElementOriginMapTestFixture + { + private XmiElementOriginMap originMap; + + [SetUp] + public void Setup() + { + this.originMap = new XmiElementOriginMap(); + } + + [Test] + public void Verify_that_element_can_be_registered_and_retrieved() + { + var elementId = Guid.NewGuid(); + var sourceFile = new Uri("file:///C:/test/model.sysmlx"); + + this.originMap.Register(elementId, sourceFile); + + Assert.That(this.originMap.GetSourceFile(elementId), Is.EqualTo(sourceFile)); + } + + [Test] + public void Verify_that_GetSourceFile_returns_null_for_unregistered_element() + { + var elementId = Guid.NewGuid(); + + Assert.That(this.originMap.GetSourceFile(elementId), Is.Null); + } + + [Test] + public void Verify_that_GetElementsInFile_returns_correct_elements() + { + var sourceFile = new Uri("file:///C:/test/model.sysmlx"); + var element1 = Guid.NewGuid(); + var element2 = Guid.NewGuid(); + var element3 = Guid.NewGuid(); + var otherFile = new Uri("file:///C:/test/other.sysmlx"); + + this.originMap.Register(element1, sourceFile); + this.originMap.Register(element2, sourceFile); + this.originMap.Register(element3, otherFile); + + var elementsInFile = this.originMap.GetElementsInFile(sourceFile).ToList(); + + Assert.That(elementsInFile, Has.Count.EqualTo(2)); + Assert.That(elementsInFile, Does.Contain(element1)); + Assert.That(elementsInFile, Does.Contain(element2)); + Assert.That(elementsInFile, Does.Not.Contain(element3)); + } + + [Test] + public void Verify_that_GetAllSourceFiles_returns_distinct_files() + { + var file1 = new Uri("file:///C:/test/model1.sysmlx"); + var file2 = new Uri("file:///C:/test/model2.sysmlx"); + + this.originMap.Register(Guid.NewGuid(), file1); + this.originMap.Register(Guid.NewGuid(), file1); + this.originMap.Register(Guid.NewGuid(), file2); + + var allFiles = this.originMap.GetAllSourceFiles().ToList(); + + Assert.That(allFiles, Has.Count.EqualTo(2)); + Assert.That(allFiles, Does.Contain(file1)); + Assert.That(allFiles, Does.Contain(file2)); + } + + [Test] + public void Verify_that_root_namespace_can_be_registered_and_retrieved() + { + var sourceFile = new Uri("file:///C:/test/model.sysmlx"); + var rootNamespaceId = Guid.NewGuid(); + + this.originMap.RegisterRootNamespace(sourceFile, rootNamespaceId); + + Assert.That(this.originMap.GetRootNamespaceId(sourceFile), Is.EqualTo(rootNamespaceId)); + } + + [Test] + public void Verify_that_GetRootNamespaceId_returns_empty_guid_for_unregistered_file() + { + var sourceFile = new Uri("file:///C:/test/model.sysmlx"); + + Assert.That(this.originMap.GetRootNamespaceId(sourceFile), Is.EqualTo(Guid.Empty)); + } + + [Test] + public void Verify_that_registering_same_element_overwrites_source_file() + { + var elementId = Guid.NewGuid(); + var file1 = new Uri("file:///C:/test/model1.sysmlx"); + var file2 = new Uri("file:///C:/test/model2.sysmlx"); + + this.originMap.Register(elementId, file1); + this.originMap.Register(elementId, file2); + + Assert.That(this.originMap.GetSourceFile(elementId), Is.EqualTo(file2)); + } + } +} diff --git a/SysML2.NET.Serializer.Xmi/DeSerializer.cs b/SysML2.NET.Serializer.Xmi/DeSerializer.cs index b97c584ed..116df4aba 100644 --- a/SysML2.NET.Serializer.Xmi/DeSerializer.cs +++ b/SysML2.NET.Serializer.Xmi/DeSerializer.cs @@ -1,20 +1,20 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // -// +// // Copyright 2022-2026 Starion Group S.A. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // // ------------------------------------------------------------------------------------------------ @@ -33,8 +33,9 @@ namespace SysML2.NET.Serializer.Xmi using SysML2.NET.Common; using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Serializer.Xmi.Extensions; using SysML2.NET.Serializer.Xmi.Readers; - + /// /// The purpose of the is to deserialize a XMI to /// an and @@ -42,45 +43,41 @@ namespace SysML2.NET.Serializer.Xmi public class DeSerializer : IDeSerializer { /// - /// The injected storing read + /// The injected to produce logs statement /// - private readonly IXmiDataCache cache; + private readonly ILogger logger; /// - /// The injected providing external reference file resolve + /// The injected used to set up logging /// - private readonly IExternalReferenceService externalReferenceService; - + private readonly ILoggerFactory loggerFactory; + /// - /// The injected to produce logs statement + /// The injected storing read /// - private readonly ILogger logger; + private readonly XmiDataCache cache; /// - /// The injected used to set up logging + /// The injected providing external reference file resolve /// - private readonly ILoggerFactory loggerFactory; + private readonly ExternalReferenceService externalReferenceService; /// /// The injected providing resolve feature based on XMI row type /// - private readonly IXmiDataReaderFacade xmiDataReaderFacade; + private readonly XmiDataReaderFacade xmiDataReaderFacade; /// Initializes a new instance of the class. - /// The injected providing external reference file resolve - /// - /// The injected providing - /// resolve feature based on XMI row type - /// - /// The injected storing read /// The injected used to set up logging - public DeSerializer(IExternalReferenceService externalReferenceService, IXmiDataReaderFacade xmiDataReaderFacade, IXmiDataCache cache, ILoggerFactory loggerFactory) + public DeSerializer(ILoggerFactory loggerFactory) { this.loggerFactory = loggerFactory ?? NullLoggerFactory.Instance; this.logger = this.loggerFactory.CreateLogger(); - this.cache = cache; - this.externalReferenceService = externalReferenceService; - this.xmiDataReaderFacade = xmiDataReaderFacade; + + this.externalReferenceService = new ExternalReferenceService(this.loggerFactory.CreateLogger()); + this.cache = new XmiDataCache(new PocoReferenceResolveExtensionsFacade(), this.loggerFactory.CreateLogger()); + + this.xmiDataReaderFacade = new XmiDataReaderFacade(); } /// @@ -96,7 +93,31 @@ public DeSerializer(IExternalReferenceService externalReferenceService, IXmiData /// public INamespace DeSerialize(Uri fileLocation) { - return this.DeSerialize(fileLocation, true); + return this.DeSerialize(fileLocation, true, null); + } + + /// + /// Deserializes the XMI file to a read , tracking element origins + /// + /// + /// the that locates the XMI file + /// + /// + /// The to populate with element-to-file associations + /// + /// If the or is null + /// If the does not locate an existing file + /// + /// The read + /// + public INamespace DeSerialize(Uri fileLocation, IXmiElementOriginMap elementOriginMap) + { + if (elementOriginMap == null) + { + throw new ArgumentNullException(nameof(elementOriginMap)); + } + + return this.DeSerialize(fileLocation, true, elementOriginMap); } /// @@ -113,7 +134,32 @@ public INamespace DeSerialize(Uri fileLocation) /// public Task DeSerializeAsync(Uri fileLocation, CancellationToken cancellationToken = default) { - return this.DeSerializeAsync(fileLocation, true, cancellationToken); + return this.DeSerializeAsync(fileLocation, true, null, cancellationToken); + } + + /// + /// Deserializes asynchronously the XMI file to a read , tracking element origins + /// + /// + /// the that locates the XMI file + /// + /// + /// The to populate with element-to-file associations + /// + /// An optional to cancel the read process + /// If the or is null + /// If the does not locate an existing file + /// + /// An awaitable with the read + /// + public Task DeSerializeAsync(Uri fileLocation, IXmiElementOriginMap elementOriginMap, CancellationToken cancellationToken = default) + { + if (elementOriginMap == null) + { + throw new ArgumentNullException(nameof(elementOriginMap)); + } + + return this.DeSerializeAsync(fileLocation, true, elementOriginMap, cancellationToken); } /// @@ -123,13 +169,14 @@ public Task DeSerializeAsync(Uri fileLocation, CancellationToken can /// the that locates the XMI file /// /// A value indicating whether the reading occurs on the root node + /// The optional to track element-to-file associations /// An optional to cancel the read process /// If the is null /// If the does not locate an existing file /// /// An awaitable with the read /// - private async Task DeSerializeAsync(Uri fileLocation, bool isRoot, CancellationToken cancellationToken) + private async Task DeSerializeAsync(Uri fileLocation, bool isRoot, IXmiElementOriginMap elementOriginMap, CancellationToken cancellationToken) { AssertValidUri(fileLocation, out var fileInfo); @@ -138,7 +185,7 @@ private async Task DeSerializeAsync(Uri fileLocation, bool isRoot, C this.logger.LogInformation("start deserializing from {Path}", fileInfo.Name); var stopWatch = Stopwatch.StartNew(); - var result = await this.ReadAsync(fileStream, fileLocation, isRoot, cancellationToken); + var result = await this.ReadAsync(fileStream, fileLocation, isRoot, elementOriginMap, cancellationToken); this.logger.LogInformation("File {Path} deserialized in {ElapsedMilliseconds}[ms]", fileInfo.Name, stopWatch.ElapsedMilliseconds); @@ -153,11 +200,12 @@ private async Task DeSerializeAsync(Uri fileLocation, bool isRoot, C /// the that locates the XMI file /// /// A value indicating whether the reading occurs on the root node + /// The optional to track element-to-file associations /// An optional to cancel the read process /// /// An awaitable with the read /// - private async Task ReadAsync(Stream stream, Uri fileLocation, bool isRoot, CancellationToken cancellationToken) + private async Task ReadAsync(Stream stream, Uri fileLocation, bool isRoot, IXmiElementOriginMap elementOriginMap, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { @@ -195,11 +243,14 @@ private async Task ReadAsync(Stream stream, Uri fileLocation, bool i return existingNamespace; } - var readNamespace = (INamespace)await this.xmiDataReaderFacade.QueryXmiDataAsync(xmlReader, this.cache, fileLocation, this.externalReferenceService, this.loggerFactory, xmlReader.Name); + var readNamespace = (INamespace)await this.xmiDataReaderFacade.QueryXmiDataAsync(xmlReader, this.cache, fileLocation, this.externalReferenceService, this.loggerFactory, xmlReader.Name, elementOriginMap); + + elementOriginMap?.RegisterRootNamespace(fileLocation, readNamespace.Id); + stopWatch.Stop(); this.logger.LogTrace("finished to read xml {DocumentName} in {ElapsedMilliseconds}[ms]", fileInfo.Name, stopWatch.ElapsedMilliseconds); - await this.ResolveExternalReferenceAsync(cancellationToken); + await this.ResolveExternalReferenceAsync(elementOriginMap, cancellationToken); if (isRoot) { @@ -216,12 +267,13 @@ private async Task ReadAsync(Stream stream, Uri fileLocation, bool i /// the that locates the XMI file /// /// A value indicating whether the reading occurs on the root node + /// The optional to track element-to-file associations /// If the is null /// If the does not locate an existing file /// /// The read /// - private INamespace DeSerialize(Uri fileLocation, bool isRoot) + private INamespace DeSerialize(Uri fileLocation, bool isRoot, IXmiElementOriginMap elementOriginMap) { AssertValidUri(fileLocation, out var fileInfo); @@ -230,7 +282,7 @@ private INamespace DeSerialize(Uri fileLocation, bool isRoot) this.logger.LogInformation("start deserializing from {Path}", fileInfo.Name); var stopWatch = Stopwatch.StartNew(); - var result = this.Read(fileStream, fileLocation, isRoot); + var result = this.Read(fileStream, fileLocation, isRoot, elementOriginMap); this.logger.LogInformation("File {Path} deserialized in {ElapsedMilliseconds}[ms]", fileInfo.Name, stopWatch.ElapsedMilliseconds); @@ -243,8 +295,9 @@ private INamespace DeSerialize(Uri fileLocation, bool isRoot) /// The content /// The to locate the original /// A value indicating whether the reading occurs on the root node + /// The optional to track element-to-file associations /// The read - private INamespace Read(Stream stream, Uri fileLocation, bool isRoot) + private INamespace Read(Stream stream, Uri fileLocation, bool isRoot, IXmiElementOriginMap elementOriginMap) { stream.Seek(0, SeekOrigin.Begin); var stopWatch = Stopwatch.StartNew(); @@ -274,11 +327,14 @@ private INamespace Read(Stream stream, Uri fileLocation, bool isRoot) return existingNamespace; } - var readNamespace = (INamespace)this.xmiDataReaderFacade.QueryXmiData(xmlReader, this.cache, fileLocation, this.externalReferenceService, this.loggerFactory, xmlReader.Name); + var readNamespace = (INamespace)this.xmiDataReaderFacade.QueryXmiData(xmlReader, this.cache, fileLocation, this.externalReferenceService, this.loggerFactory, xmlReader.Name, elementOriginMap); + + elementOriginMap?.RegisterRootNamespace(fileLocation, readNamespace.Id); + stopWatch.Stop(); this.logger.LogTrace("finished to read xml {DocumentName} in {ElapsedMilliseconds}[ms]", fileInfo.Name, stopWatch.ElapsedMilliseconds); - this.ResolveExternalReference(); + this.ResolveExternalReference(elementOriginMap); if (isRoot) { @@ -291,28 +347,30 @@ private INamespace Read(Stream stream, Uri fileLocation, bool isRoot) /// /// Resolve and read all external references /// - private void ResolveExternalReference() + /// The optional to track element-to-file associations + private void ResolveExternalReference(IXmiElementOriginMap elementOriginMap) { var references = this.externalReferenceService.GetExternalReferencesToProcess(); foreach (var reference in references) { - this.DeSerialize(reference, false); + this.DeSerialize(reference, false, elementOriginMap); } } /// /// Resolve and read all external references asynchronously /// + /// The optional to track element-to-file associations /// The to cancel read process /// An awaitable - private async Task ResolveExternalReferenceAsync(CancellationToken cancellationToken) + private async Task ResolveExternalReferenceAsync(IXmiElementOriginMap elementOriginMap, CancellationToken cancellationToken) { var references = this.externalReferenceService.GetExternalReferencesToProcess(); foreach (var reference in references) { - await this.DeSerializeAsync(reference, false, cancellationToken); + await this.DeSerializeAsync(reference, false, elementOriginMap, cancellationToken); } } diff --git a/SysML2.NET.Serializer.Xmi/Extensions/DataExtension.cs b/SysML2.NET.Serializer.Xmi/Extensions/DataExtension.cs new file mode 100644 index 000000000..c7b663003 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Extensions/DataExtension.cs @@ -0,0 +1,55 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Extensions +{ + using System; + + using SysML2.NET.Common; + + /// + /// Extension class for the interface + /// + public static class DataExtension + { + /// + /// Verify that the current can be target via an Id reference or not + /// + /// The that needs to be verified + /// The provided that should be used to verify the registration of the + /// The that locates an XMI file + /// true if the can be referenced via identifier, false otherwise + public static bool QueryIsValidIdRef(this IData data, IXmiElementOriginMap elementOriginMap, Uri currentFileUri) + { + if (data == null) + { + throw new ArgumentNullException(nameof(data)); + } + + if (elementOriginMap == null || currentFileUri == null) + { + return true; + } + + var sourceFile = elementOriginMap.GetSourceFile(data.Id); + return sourceFile == null || sourceFile == currentFileUri; + } + } +} diff --git a/SysML2.NET.Serializer.Xmi/IDeSerializer.cs b/SysML2.NET.Serializer.Xmi/IDeSerializer.cs index b586a02c6..b8e6a5a3e 100644 --- a/SysML2.NET.Serializer.Xmi/IDeSerializer.cs +++ b/SysML2.NET.Serializer.Xmi/IDeSerializer.cs @@ -48,6 +48,22 @@ public interface IDeSerializer /// INamespace DeSerialize(Uri fileLocation); + /// + /// Deserializes the XMI file to a read , tracking element origins + /// + /// + /// the that locates the XMI file + /// + /// + /// The to populate with element-to-file associations + /// + /// If the or is null + /// If the does not locate an existing file + /// + /// The read + /// + INamespace DeSerialize(Uri fileLocation, IXmiElementOriginMap elementOriginMap); + /// /// Deserializes asynchronously the XMI file to a read /// @@ -61,5 +77,22 @@ public interface IDeSerializer /// An awaitable with the read /// Task DeSerializeAsync(Uri fileLocation, CancellationToken cancellationToken = default); + + /// + /// Deserializes asynchronously the XMI file to a read , tracking element origins + /// + /// + /// the that locates the XMI file + /// + /// + /// The to populate with element-to-file associations + /// + /// An optional to cancel the read process + /// If the or is null + /// If the does not locate an existing file + /// + /// An awaitable with the read + /// + Task DeSerializeAsync(Uri fileLocation, IXmiElementOriginMap elementOriginMap, CancellationToken cancellationToken = default); } } diff --git a/SysML2.NET.Serializer.Xmi/ISerializer.cs b/SysML2.NET.Serializer.Xmi/ISerializer.cs index 1ea7c6ce9..df7c63d86 100644 --- a/SysML2.NET.Serializer.Xmi/ISerializer.cs +++ b/SysML2.NET.Serializer.Xmi/ISerializer.cs @@ -1,98 +1,128 @@ // ------------------------------------------------------------------------------------------------- // -// +// // Copyright 2022-2026 Starion Group S.A. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// +// // // ------------------------------------------------------------------------------------------------ namespace SysML2.NET.Serializer.Xmi { + using System; using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Serializer.Xmi.Writers; /// - /// The purpose of the is to write an and + /// The purpose of the is to write an /// as XMI to a /// public interface ISerializer { /// - /// Serialize an as XMI to a target + /// Serialize an as XMI to a target /// - /// - /// The that shall be serialized - /// - /// - /// Asserts that derived properties should also be part of the serialization + /// + /// The that shall be serialized /// + /// The instance that provides writer output configuration /// /// The target /// - void Serialize(IEnumerable dataItems, bool includeDerivedProperties, Stream stream); + void Serialize(INamespace @namespace, XmiWriterOptions writerOptions, Stream stream); /// - /// Serialize an as XMI to a target + /// Serialize an as XMI to a target , + /// using an origin map for href reconstruction /// - /// - /// The that shall be serialized - /// - /// - /// Asserts that derived properties should also be part of the serialization + /// + /// The that shall be serialized /// + /// The instance that provides writer output configuration /// /// The target /// - void Serialize(IData dataItem, bool includeDerivedProperties, Stream stream); + /// + /// The optional for href reconstruction + /// + /// + /// The optional of the current output file for relative href computation + /// + void Serialize(INamespace @namespace, XmiWriterOptions writerOptions, Stream stream, IXmiElementOriginMap elementOriginMap, Uri currentFileUri); /// - /// Asynchronously serialize an as XMI to a target + /// Serialize an to multiple XMI files based on the element origin map /// - /// - /// The that shall be serialized + /// The root containing all elements + /// The tracking element-to-file associations + /// The target directory for output files + /// The instance that provides writer output configuration + void Serialize(INamespace rootNamespace, IXmiElementOriginMap elementOriginMap, DirectoryInfo outputDirectory, XmiWriterOptions writerOptions); + + /// + /// Asynchronously serialize an as XMI to a target + /// + /// + /// The that shall be serialized /// /// /// The target /// - /// - /// Asserts that derived properties should also be part of the serialization - /// + /// The instance that provides writer output configuration /// /// The used to cancel the operation /// - Task SerializeAsync(IEnumerable dataItems, bool includeDerivedProperties, Stream stream, CancellationToken cancellationToken); + Task SerializeAsync(INamespace @namespace, XmiWriterOptions writerOptions, Stream stream, CancellationToken cancellationToken); /// - /// Asynchronously serialize an as XMI to a target + /// Asynchronously serialize an as XMI to a target , + /// using an origin map for href reconstruction /// - /// - /// The that shall be serialized - /// - /// - /// Asserts that derived properties should also be part of the serialization + /// + /// The that shall be serialized /// + /// The instance that provides writer output configuration /// /// The target /// + /// + /// The optional for href reconstruction + /// + /// + /// The optional of the current output file for relative href computation + /// + /// + /// The used to cancel the operation + /// + Task SerializeAsync(INamespace @namespace, XmiWriterOptions writerOptions, Stream stream, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, CancellationToken cancellationToken); + + /// + /// Asynchronously serialize an to multiple XMI files based on the element origin map + /// + /// The root containing all elements + /// The tracking element-to-file associations + /// The target directory for output files + /// The instance that provides writer output configuration /// /// The used to cancel the operation /// - Task SerializeAsync(IData dataItem, bool includeDerivedProperties, Stream stream, CancellationToken cancellationToken); + Task SerializeAsync(INamespace rootNamespace, IXmiElementOriginMap elementOriginMap, DirectoryInfo outputDirectory, XmiWriterOptions writerOptions, CancellationToken cancellationToken); } } diff --git a/SysML2.NET.Serializer.Xmi/IXmiElementOriginMap.cs b/SysML2.NET.Serializer.Xmi/IXmiElementOriginMap.cs new file mode 100644 index 000000000..343f1192f --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/IXmiElementOriginMap.cs @@ -0,0 +1,73 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi +{ + using System; + using System.Collections.Generic; + + /// + /// Tracks the association between elements and the XMI source files they were deserialized from. + /// This enables faithful round-trip serialization back to multiple XMI files with correct href references. + /// + public interface IXmiElementOriginMap + { + /// + /// Registers the source file for a given element + /// + /// The identifier of the element + /// The of the source XMI file + void Register(Guid elementId, Uri sourceFile); + + /// + /// Gets the source file for a given element + /// + /// The identifier of the element + /// The of the source file, or null if not tracked + Uri GetSourceFile(Guid elementId); + + /// + /// Gets all element identifiers that were deserialized from the given source file + /// + /// The of the source XMI file + /// An of element identifiers + IEnumerable GetElementsInFile(Uri sourceFile); + + /// + /// Gets all source files that have been registered + /// + /// An of source file URIs + IEnumerable GetAllSourceFiles(); + + /// + /// Registers the root namespace identifier for a given source file + /// + /// The of the source XMI file + /// The of the root namespace element + void RegisterRootNamespace(Uri sourceFile, Guid rootNamespaceId); + + /// + /// Gets the root namespace identifier for a given source file + /// + /// The of the source XMI file + /// The of the root namespace, or if not registered + Guid GetRootNamespaceId(Uri sourceFile); + } +} diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AcceptActionUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AcceptActionUsageReader.cs index 3511bd613..4e90f4101 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AcceptActionUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AcceptActionUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class AcceptActionUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public AcceptActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public AcceptActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AcceptActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override IAcceptActionUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AcceptActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AcceptActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AcceptActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ActionDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ActionDefinitionReader.cs index 75d1da08a..fd460a217 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ActionDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ActionDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -62,6 +63,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -86,7 +88,8 @@ public class ActionDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ActionDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ActionDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -132,6 +135,8 @@ public override IActionDefinition Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ActionDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -225,6 +230,10 @@ public override IActionDefinition Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -241,6 +250,10 @@ public override IActionDefinition Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -303,7 +316,14 @@ public override IActionDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -315,7 +335,14 @@ public override IActionDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -327,7 +354,14 @@ public override IActionDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -339,7 +373,14 @@ public override IActionDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -351,7 +392,14 @@ public override IActionDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -365,12 +413,18 @@ public override IActionDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -386,12 +440,18 @@ public override IActionDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -399,6 +459,10 @@ public override IActionDefinition Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ActionDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -448,6 +512,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ActionDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -541,6 +607,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -557,6 +627,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -619,7 +693,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -631,7 +712,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -643,7 +731,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -655,7 +750,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -667,7 +769,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -681,12 +790,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -702,12 +817,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -715,6 +836,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ActionDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ActionUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ActionUsageReader.cs index 53a7ddbdf..e10dcc4df 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ActionUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ActionUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -65,6 +66,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -89,7 +91,8 @@ public class ActionUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -135,6 +138,8 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -163,7 +168,7 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -308,6 +313,10 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -324,13 +333,17 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -384,7 +397,14 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -408,7 +428,14 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -420,7 +447,14 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -432,7 +466,14 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -444,7 +485,14 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -456,7 +504,14 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -468,7 +523,14 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -480,7 +542,14 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -492,7 +561,14 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -504,7 +580,14 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -516,7 +599,14 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -528,7 +618,14 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -540,7 +637,14 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -554,12 +658,18 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -575,12 +685,18 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -594,12 +710,23 @@ public override IActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -649,6 +776,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -677,7 +806,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -822,6 +951,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -838,13 +971,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -898,7 +1035,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -922,7 +1066,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -934,7 +1085,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -946,7 +1104,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -958,7 +1123,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -970,7 +1142,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -982,7 +1161,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -994,7 +1180,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1006,7 +1199,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1018,7 +1218,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1030,7 +1237,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1042,7 +1256,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1054,7 +1275,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1068,12 +1296,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1089,12 +1323,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1108,12 +1348,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ActorMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ActorMembershipReader.cs index cf1a0377c..a1a308090 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ActorMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ActorMembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.Parts; using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class ActorMembershipReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ActorMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ActorMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override IActorMembership Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ActorMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -175,6 +180,10 @@ public override IActorMembership Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -195,6 +204,10 @@ public override IActorMembership Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -211,6 +224,10 @@ public override IActorMembership Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -221,13 +238,17 @@ public override IActorMembership Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -293,7 +314,14 @@ public override IActorMembership Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -305,7 +333,14 @@ public override IActorMembership Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -319,12 +354,18 @@ public override IActorMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -340,12 +381,18 @@ public override IActorMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -361,12 +408,18 @@ public override IActorMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -382,12 +435,18 @@ public override IActorMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -401,12 +460,23 @@ public override IActorMembership Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ActorMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -456,6 +526,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ActorMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -519,6 +591,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -539,6 +615,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -555,6 +635,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -565,13 +649,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -637,7 +725,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -649,7 +744,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -663,12 +765,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -684,12 +792,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -705,12 +819,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -726,12 +846,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -745,12 +871,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ActorMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AllocationDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AllocationDefinitionReader.cs index 62bbacb6e..664625228 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AllocationDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AllocationDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -62,6 +63,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -86,7 +88,8 @@ public class AllocationDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public AllocationDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public AllocationDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -132,6 +135,8 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AllocationDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -235,6 +240,10 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -255,6 +264,10 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -271,6 +284,10 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -281,6 +298,10 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -343,7 +364,14 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -355,7 +383,14 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -367,7 +402,14 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -379,7 +421,14 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -391,7 +440,14 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -403,7 +459,14 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -417,12 +480,18 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -438,12 +507,18 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -459,12 +534,18 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -480,12 +561,18 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -493,6 +580,10 @@ public override IAllocationDefinition Read(XmlReader xmiReader, Uri currentLocat break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AllocationDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -542,6 +633,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AllocationDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -645,6 +738,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -665,6 +762,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -681,6 +782,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -691,6 +796,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -753,7 +862,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -765,7 +881,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -777,7 +900,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -789,7 +919,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -801,7 +938,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -813,7 +957,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -827,12 +978,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -848,12 +1005,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -869,12 +1032,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -890,12 +1059,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -903,6 +1078,10 @@ public override async Task ReadAsync(XmlReader xmiReader, break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AllocationDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AllocationUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AllocationUsageReader.cs index 6f239134b..1e3c568bf 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AllocationUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AllocationUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -67,6 +68,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -91,7 +93,8 @@ public class AllocationUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public AllocationUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public AllocationUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -137,6 +140,8 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AllocationUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -165,7 +170,7 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -320,6 +325,10 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -340,6 +349,10 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -356,6 +369,10 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -366,13 +383,17 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -426,7 +447,14 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -450,7 +478,14 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -462,7 +497,14 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -474,7 +516,14 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -486,7 +535,14 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -498,7 +554,14 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -510,7 +573,14 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -522,7 +592,14 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -534,7 +611,14 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -546,7 +630,14 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -558,7 +649,14 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -570,7 +668,14 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -582,7 +687,14 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -594,7 +706,14 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -608,12 +727,18 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -629,12 +754,18 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -650,12 +781,18 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -671,12 +808,18 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -690,12 +833,23 @@ public override IAllocationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AllocationUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -745,6 +899,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AllocationUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -773,7 +929,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -928,6 +1084,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -948,6 +1108,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -964,6 +1128,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -974,13 +1142,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -1034,7 +1206,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -1058,7 +1237,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -1070,7 +1256,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -1082,7 +1275,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -1094,7 +1294,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1106,7 +1313,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1118,7 +1332,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -1130,7 +1351,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1142,7 +1370,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1154,7 +1389,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1166,7 +1408,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1178,7 +1427,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1190,7 +1446,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1202,7 +1465,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1216,12 +1486,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -1237,12 +1513,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1258,12 +1540,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -1279,12 +1567,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1298,12 +1592,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AllocationUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnalysisCaseDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnalysisCaseDefinitionReader.cs index 076ecad0f..08866a976 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnalysisCaseDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnalysisCaseDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -63,6 +64,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -87,7 +89,8 @@ public class AnalysisCaseDefinitionReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public AnalysisCaseDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public AnalysisCaseDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -133,6 +136,8 @@ public override IAnalysisCaseDefinition Read(XmlReader xmiReader, Uri currentLoc this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AnalysisCaseDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -226,6 +231,10 @@ public override IAnalysisCaseDefinition Read(XmlReader xmiReader, Uri currentLoc { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -242,6 +251,10 @@ public override IAnalysisCaseDefinition Read(XmlReader xmiReader, Uri currentLoc { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -304,7 +317,14 @@ public override IAnalysisCaseDefinition Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -316,7 +336,14 @@ public override IAnalysisCaseDefinition Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -328,7 +355,14 @@ public override IAnalysisCaseDefinition Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -340,7 +374,14 @@ public override IAnalysisCaseDefinition Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -352,7 +393,14 @@ public override IAnalysisCaseDefinition Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -366,12 +414,18 @@ public override IAnalysisCaseDefinition Read(XmlReader xmiReader, Uri currentLoc { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -387,12 +441,18 @@ public override IAnalysisCaseDefinition Read(XmlReader xmiReader, Uri currentLoc { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -400,6 +460,10 @@ public override IAnalysisCaseDefinition Read(XmlReader xmiReader, Uri currentLoc break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AnalysisCaseDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -449,6 +513,8 @@ public override async Task ReadAsync(XmlReader xmiReade this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AnalysisCaseDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -542,6 +608,10 @@ public override async Task ReadAsync(XmlReader xmiReade { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -558,6 +628,10 @@ public override async Task ReadAsync(XmlReader xmiReade { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -620,7 +694,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -632,7 +713,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -644,7 +732,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -656,7 +751,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -668,7 +770,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -682,12 +791,18 @@ public override async Task ReadAsync(XmlReader xmiReade { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -703,12 +818,18 @@ public override async Task ReadAsync(XmlReader xmiReade { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -716,6 +837,10 @@ public override async Task ReadAsync(XmlReader xmiReade break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AnalysisCaseDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnalysisCaseUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnalysisCaseUsageReader.cs index 6711c1e9e..bf2d5266f 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnalysisCaseUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnalysisCaseUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class AnalysisCaseUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public AnalysisCaseUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public AnalysisCaseUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AnalysisCaseUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override IAnalysisCaseUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AnalysisCaseUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AnalysisCaseUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AnalysisCaseUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnnotatingElementReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnnotatingElementReader.cs index 8fc9178cb..1c93a4bfd 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnnotatingElementReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnnotatingElementReader.cs @@ -33,9 +33,11 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -60,7 +62,8 @@ public class AnnotatingElementReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public AnnotatingElementReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public AnnotatingElementReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -106,6 +109,8 @@ public override IAnnotatingElement Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AnnotatingElement", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -159,6 +164,10 @@ public override IAnnotatingElement Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -175,6 +184,10 @@ public override IAnnotatingElement Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -237,7 +250,14 @@ public override IAnnotatingElement Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -251,12 +271,18 @@ public override IAnnotatingElement Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -272,12 +298,18 @@ public override IAnnotatingElement Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -285,6 +317,10 @@ public override IAnnotatingElement Read(XmlReader xmiReader, Uri currentLocation break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AnnotatingElement at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -334,6 +370,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AnnotatingElement", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -387,6 +425,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -403,6 +445,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -465,7 +511,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -479,12 +532,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -500,12 +559,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -513,6 +578,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AnnotatingElement at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnnotationReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnnotationReader.cs index 954d5446e..e3dd30223 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnnotationReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AnnotationReader.cs @@ -33,9 +33,11 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -60,7 +62,8 @@ public class AnnotationReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public AnnotationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public AnnotationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -106,6 +109,8 @@ public override IAnnotation Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Annotation", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -124,6 +129,10 @@ public override IAnnotation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "annotatedElement", annotatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'annotatedElement' on element {ElementId}", annotatedElementXmlAttribute, poco.Id); + } } var declaredNameXmlAttribute = xmiReader.GetAttribute("declaredName"); @@ -179,6 +188,10 @@ public override IAnnotation Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -199,6 +212,10 @@ public override IAnnotation Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -215,6 +232,10 @@ public override IAnnotation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -225,6 +246,10 @@ public override IAnnotation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -253,12 +278,18 @@ public override IAnnotation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var annotatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "annotatedElement", annotatedElementId); + if (Guid.TryParse(hrefSplit[1], out var annotatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "annotatedElement", annotatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'annotatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var annotatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var annotatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.AnnotatedElement = annotatedElementValue; } @@ -308,7 +339,14 @@ public override IAnnotation Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -320,7 +358,14 @@ public override IAnnotation Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -334,12 +379,18 @@ public override IAnnotation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -355,12 +406,18 @@ public override IAnnotation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -376,12 +433,18 @@ public override IAnnotation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -397,12 +460,18 @@ public override IAnnotation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -410,6 +479,10 @@ public override IAnnotation Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Annotation at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -459,6 +532,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Annotation", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -477,6 +552,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "annotatedElement", annotatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'annotatedElement' on element {ElementId}", annotatedElementXmlAttribute, poco.Id); + } } var declaredNameXmlAttribute = xmiReader.GetAttribute("declaredName"); @@ -532,6 +611,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -552,6 +635,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -568,6 +655,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -578,6 +669,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -606,12 +701,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var annotatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "annotatedElement", annotatedElementId); + if (Guid.TryParse(hrefSplit[1], out var annotatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "annotatedElement", annotatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'annotatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var annotatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var annotatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.AnnotatedElement = annotatedElementValue; } @@ -661,7 +762,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -673,7 +781,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -687,12 +802,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -708,12 +829,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -729,12 +856,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -750,12 +883,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -763,6 +902,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Annotation at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssertConstraintUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssertConstraintUsageReader.cs index 05a84fd1e..2278487c5 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssertConstraintUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssertConstraintUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class AssertConstraintUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public AssertConstraintUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public AssertConstraintUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AssertConstraintUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -319,6 +324,10 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -335,13 +344,17 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -395,7 +408,14 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -419,7 +439,14 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -431,7 +458,14 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -443,7 +477,14 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -455,7 +496,14 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -467,7 +515,14 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -479,7 +534,14 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -491,7 +553,14 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -503,7 +572,14 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isNegatedValue)) { - poco.IsNegated = bool.Parse(isNegatedValue); + if (bool.TryParse(isNegatedValue, out var isNegatedValueAsBool)) + { + poco.IsNegated = isNegatedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isNegated' on element {ElementId}", isNegatedValue, poco.Id); + } } break; @@ -515,7 +591,14 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -527,7 +610,14 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -539,7 +629,14 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -551,7 +648,14 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -563,7 +667,14 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -577,12 +688,18 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -598,12 +715,18 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -617,12 +740,23 @@ public override IAssertConstraintUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AssertConstraintUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -672,6 +806,8 @@ public override async Task ReadAsync(XmlReader xmiReader this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AssertConstraintUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -700,7 +836,7 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -855,6 +991,10 @@ public override async Task ReadAsync(XmlReader xmiReader { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -871,13 +1011,17 @@ public override async Task ReadAsync(XmlReader xmiReader { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -931,7 +1075,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -955,7 +1106,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -967,7 +1125,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -979,7 +1144,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -991,7 +1163,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1003,7 +1182,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1015,7 +1201,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1027,7 +1220,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1039,7 +1239,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isNegatedValue)) { - poco.IsNegated = bool.Parse(isNegatedValue); + if (bool.TryParse(isNegatedValue, out var isNegatedValueAsBool)) + { + poco.IsNegated = isNegatedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isNegated' on element {ElementId}", isNegatedValue, poco.Id); + } } break; @@ -1051,7 +1258,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1063,7 +1277,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1075,7 +1296,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1087,7 +1315,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1099,7 +1334,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1113,12 +1355,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1134,12 +1382,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1153,12 +1407,23 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AssertConstraintUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssignmentActionUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssignmentActionUsageReader.cs index 7311f46d3..e6cdb3cf0 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssignmentActionUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssignmentActionUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class AssignmentActionUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public AssignmentActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public AssignmentActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AssignmentActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override IAssignmentActionUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AssignmentActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AssignmentActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AssignmentActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssociationReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssociationReader.cs index ccf7b99f2..700d1b020 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssociationReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssociationReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -40,6 +41,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -64,7 +66,8 @@ public class AssociationReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public AssociationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public AssociationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -110,6 +113,8 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Association", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -193,6 +198,10 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -213,6 +222,10 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -229,6 +242,10 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -239,6 +256,10 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -301,7 +322,14 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -313,7 +341,14 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -325,7 +360,14 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -337,7 +379,14 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -351,12 +400,18 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -372,12 +427,18 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -393,12 +454,18 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -414,12 +481,18 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -427,6 +500,10 @@ public override IAssociation Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Association at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -476,6 +553,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Association", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -559,6 +638,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -579,6 +662,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -595,6 +682,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -605,6 +696,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -667,7 +762,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -679,7 +781,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -691,7 +800,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -703,7 +819,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -717,12 +840,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -738,12 +867,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -759,12 +894,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -780,12 +921,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -793,6 +940,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Association at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssociationStructureReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssociationStructureReader.cs index 11e8b0f2a..5ec1707ef 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssociationStructureReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AssociationStructureReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -41,6 +42,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -65,7 +67,8 @@ public class AssociationStructureReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public AssociationStructureReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public AssociationStructureReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +114,8 @@ public override IAssociationStructure Read(XmlReader xmiReader, Uri currentLocat this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AssociationStructure", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -194,6 +199,10 @@ public override IAssociationStructure Read(XmlReader xmiReader, Uri currentLocat { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -214,6 +223,10 @@ public override IAssociationStructure Read(XmlReader xmiReader, Uri currentLocat { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -230,6 +243,10 @@ public override IAssociationStructure Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -240,6 +257,10 @@ public override IAssociationStructure Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -302,7 +323,14 @@ public override IAssociationStructure Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -314,7 +342,14 @@ public override IAssociationStructure Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -326,7 +361,14 @@ public override IAssociationStructure Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -338,7 +380,14 @@ public override IAssociationStructure Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -352,12 +401,18 @@ public override IAssociationStructure Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -373,12 +428,18 @@ public override IAssociationStructure Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -394,12 +455,18 @@ public override IAssociationStructure Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -415,12 +482,18 @@ public override IAssociationStructure Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -428,6 +501,10 @@ public override IAssociationStructure Read(XmlReader xmiReader, Uri currentLocat break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AssociationStructure at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -477,6 +554,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AssociationStructure", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -560,6 +639,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -580,6 +663,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -596,6 +683,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -606,6 +697,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -668,7 +763,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -680,7 +782,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -692,7 +801,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -704,7 +820,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -718,12 +841,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -739,12 +868,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -760,12 +895,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -781,12 +922,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -794,6 +941,10 @@ public override async Task ReadAsync(XmlReader xmiReader, break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AssociationStructure at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AttributeDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AttributeDefinitionReader.cs index 35f18d2c8..4fed79314 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AttributeDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AttributeDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -62,6 +63,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -86,7 +88,8 @@ public class AttributeDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public AttributeDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public AttributeDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -132,6 +135,8 @@ public override IAttributeDefinition Read(XmlReader xmiReader, Uri currentLocati this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AttributeDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -215,6 +220,10 @@ public override IAttributeDefinition Read(XmlReader xmiReader, Uri currentLocati { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -231,6 +240,10 @@ public override IAttributeDefinition Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -293,7 +306,14 @@ public override IAttributeDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -305,7 +325,14 @@ public override IAttributeDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -317,7 +344,14 @@ public override IAttributeDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -329,7 +363,14 @@ public override IAttributeDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -343,12 +384,18 @@ public override IAttributeDefinition Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -364,12 +411,18 @@ public override IAttributeDefinition Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -377,6 +430,10 @@ public override IAttributeDefinition Read(XmlReader xmiReader, Uri currentLocati break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AttributeDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -426,6 +483,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AttributeDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -509,6 +568,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -525,6 +588,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -587,7 +654,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -599,7 +673,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -611,7 +692,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -623,7 +711,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -637,12 +732,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -658,12 +759,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -671,6 +778,10 @@ public override async Task ReadAsync(XmlReader xmiReader, break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AttributeDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AttributeUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AttributeUsageReader.cs index b4572c527..a237b0ed0 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AttributeUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/AttributeUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; @@ -63,6 +64,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -87,7 +89,8 @@ public class AttributeUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public AttributeUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public AttributeUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -133,6 +136,8 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AttributeUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -161,7 +166,7 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -296,6 +301,10 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -312,6 +321,10 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -362,7 +375,14 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -386,7 +406,14 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -398,7 +425,14 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -410,7 +444,14 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -422,7 +463,14 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -434,7 +482,14 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -446,7 +501,14 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -458,7 +520,14 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -470,7 +539,14 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -482,7 +558,14 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -494,7 +577,14 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -506,7 +596,14 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -520,12 +617,18 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -541,12 +644,18 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -554,6 +663,10 @@ public override IAttributeUsage Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AttributeUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -603,6 +716,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "AttributeUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -631,7 +746,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -766,6 +881,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -782,6 +901,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -832,7 +955,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -856,7 +986,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -868,7 +1005,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -880,7 +1024,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -892,7 +1043,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -904,7 +1062,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -916,7 +1081,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -928,7 +1100,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -940,7 +1119,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -952,7 +1138,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -964,7 +1157,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -976,7 +1176,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -990,12 +1197,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1011,12 +1224,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1024,6 +1243,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading AttributeUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BehaviorReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BehaviorReader.cs index 998412e4f..def4280dc 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BehaviorReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BehaviorReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -41,6 +42,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -65,7 +67,8 @@ public class BehaviorReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public BehaviorReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public BehaviorReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +114,8 @@ public override IBehavior Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Behavior", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -184,6 +189,10 @@ public override IBehavior Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -200,6 +209,10 @@ public override IBehavior Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -262,7 +275,14 @@ public override IBehavior Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -274,7 +294,14 @@ public override IBehavior Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -286,7 +313,14 @@ public override IBehavior Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -300,12 +334,18 @@ public override IBehavior Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -321,12 +361,18 @@ public override IBehavior Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -334,6 +380,10 @@ public override IBehavior Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Behavior at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -383,6 +433,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Behavior", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -456,6 +508,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -472,6 +528,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -534,7 +594,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -546,7 +613,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -558,7 +632,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -572,12 +653,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -593,12 +680,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -606,6 +699,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Behavior at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BindingConnectorAsUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BindingConnectorAsUsageReader.cs index aa9b86f7a..b8c2f51df 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BindingConnectorAsUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BindingConnectorAsUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; @@ -64,6 +65,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -88,7 +90,8 @@ public class BindingConnectorAsUsageReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public BindingConnectorAsUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public BindingConnectorAsUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -134,6 +137,8 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "BindingConnectorAsUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -162,7 +167,7 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -307,6 +312,10 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -327,6 +336,10 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -343,6 +356,10 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -353,6 +370,10 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -403,7 +424,14 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -427,7 +455,14 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -439,7 +474,14 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -451,7 +493,14 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -463,7 +512,14 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -475,7 +531,14 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -487,7 +550,14 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -499,7 +569,14 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -511,7 +588,14 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -523,7 +607,14 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -535,7 +626,14 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -547,7 +645,14 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -559,7 +664,14 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -573,12 +685,18 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -594,12 +712,18 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -615,12 +739,18 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -636,12 +766,18 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -649,6 +785,10 @@ public override IBindingConnectorAsUsage Read(XmlReader xmiReader, Uri currentLo break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading BindingConnectorAsUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -698,6 +838,8 @@ public override async Task ReadAsync(XmlReader xmiRead this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "BindingConnectorAsUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -726,7 +868,7 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -871,6 +1013,10 @@ public override async Task ReadAsync(XmlReader xmiRead { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -891,6 +1037,10 @@ public override async Task ReadAsync(XmlReader xmiRead { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -907,6 +1057,10 @@ public override async Task ReadAsync(XmlReader xmiRead { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -917,6 +1071,10 @@ public override async Task ReadAsync(XmlReader xmiRead { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -967,7 +1125,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -991,7 +1156,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -1003,7 +1175,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -1015,7 +1194,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -1027,7 +1213,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1039,7 +1232,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1051,7 +1251,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -1063,7 +1270,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1075,7 +1289,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1087,7 +1308,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1099,7 +1327,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1111,7 +1346,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1123,7 +1365,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1137,12 +1386,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -1158,12 +1413,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1179,12 +1440,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -1200,12 +1467,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1213,6 +1486,10 @@ public override async Task ReadAsync(XmlReader xmiRead break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading BindingConnectorAsUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BindingConnectorReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BindingConnectorReader.cs index 9a40b7849..ea3ce3a1f 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BindingConnectorReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BindingConnectorReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -41,6 +42,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -65,7 +67,8 @@ public class BindingConnectorReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public BindingConnectorReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public BindingConnectorReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +114,8 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "BindingConnector", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -139,7 +144,7 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -284,6 +289,10 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -304,6 +313,10 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -320,6 +333,10 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -330,6 +347,10 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -380,7 +401,14 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -404,7 +432,14 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -416,7 +451,14 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -428,7 +470,14 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -440,7 +489,14 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -452,7 +508,14 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -464,7 +527,14 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -476,7 +546,14 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -488,7 +565,14 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -500,7 +584,14 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -512,7 +603,14 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -524,7 +622,14 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -536,7 +641,14 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -550,12 +662,18 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -571,12 +689,18 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -592,12 +716,18 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -613,12 +743,18 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -626,6 +762,10 @@ public override IBindingConnector Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading BindingConnector at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -675,6 +815,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "BindingConnector", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -703,7 +845,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -848,6 +990,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -868,6 +1014,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -884,6 +1034,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -894,6 +1048,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -944,7 +1102,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -968,7 +1133,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -980,7 +1152,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -992,7 +1171,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -1004,7 +1190,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1016,7 +1209,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1028,7 +1228,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -1040,7 +1247,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1052,7 +1266,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1064,7 +1285,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1076,7 +1304,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1088,7 +1323,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1100,7 +1342,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1114,12 +1363,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -1135,12 +1390,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1156,12 +1417,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -1177,12 +1444,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1190,6 +1463,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading BindingConnector at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BooleanExpressionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BooleanExpressionReader.cs index 0136c897b..058f710e5 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BooleanExpressionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/BooleanExpressionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -41,6 +42,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -65,7 +67,8 @@ public class BooleanExpressionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public BooleanExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public BooleanExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +114,8 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "BooleanExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -139,7 +144,7 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -274,6 +279,10 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -290,6 +299,10 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -340,7 +353,14 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -364,7 +384,14 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -376,7 +403,14 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -388,7 +422,14 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -400,7 +441,14 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -412,7 +460,14 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -424,7 +479,14 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -436,7 +498,14 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -448,7 +517,14 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -460,7 +536,14 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -472,7 +555,14 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -484,7 +574,14 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -498,12 +595,18 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -519,12 +622,18 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -532,6 +641,10 @@ public override IBooleanExpression Read(XmlReader xmiReader, Uri currentLocation break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading BooleanExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -581,6 +694,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "BooleanExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -609,7 +724,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -744,6 +859,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -760,6 +879,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -810,7 +933,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -834,7 +964,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -846,7 +983,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -858,7 +1002,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -870,7 +1021,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -882,7 +1040,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -894,7 +1059,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -906,7 +1078,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -918,7 +1097,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -930,7 +1116,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -942,7 +1135,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -954,7 +1154,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -968,12 +1175,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -989,12 +1202,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1002,6 +1221,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading BooleanExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CalculationDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CalculationDefinitionReader.cs index 683e6af2b..9e783f04c 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CalculationDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CalculationDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -63,6 +64,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -87,7 +89,8 @@ public class CalculationDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public CalculationDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public CalculationDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -133,6 +136,8 @@ public override ICalculationDefinition Read(XmlReader xmiReader, Uri currentLoca this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "CalculationDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -226,6 +231,10 @@ public override ICalculationDefinition Read(XmlReader xmiReader, Uri currentLoca { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -242,6 +251,10 @@ public override ICalculationDefinition Read(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -304,7 +317,14 @@ public override ICalculationDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -316,7 +336,14 @@ public override ICalculationDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -328,7 +355,14 @@ public override ICalculationDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -340,7 +374,14 @@ public override ICalculationDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -352,7 +393,14 @@ public override ICalculationDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -366,12 +414,18 @@ public override ICalculationDefinition Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -387,12 +441,18 @@ public override ICalculationDefinition Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -400,6 +460,10 @@ public override ICalculationDefinition Read(XmlReader xmiReader, Uri currentLoca break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading CalculationDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -449,6 +513,8 @@ public override async Task ReadAsync(XmlReader xmiReader this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "CalculationDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -542,6 +608,10 @@ public override async Task ReadAsync(XmlReader xmiReader { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -558,6 +628,10 @@ public override async Task ReadAsync(XmlReader xmiReader { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -620,7 +694,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -632,7 +713,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -644,7 +732,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -656,7 +751,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -668,7 +770,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -682,12 +791,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -703,12 +818,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -716,6 +837,10 @@ public override async Task ReadAsync(XmlReader xmiReader break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading CalculationDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CalculationUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CalculationUsageReader.cs index 5d5a154c5..bb67e0d3a 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CalculationUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CalculationUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class CalculationUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public CalculationUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public CalculationUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "CalculationUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override ICalculationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading CalculationUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "CalculationUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading CalculationUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CaseDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CaseDefinitionReader.cs index fc614ccae..4a315d760 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CaseDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CaseDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -63,6 +64,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -87,7 +89,8 @@ public class CaseDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public CaseDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public CaseDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -133,6 +136,8 @@ public override ICaseDefinition Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "CaseDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -226,6 +231,10 @@ public override ICaseDefinition Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -242,6 +251,10 @@ public override ICaseDefinition Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -304,7 +317,14 @@ public override ICaseDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -316,7 +336,14 @@ public override ICaseDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -328,7 +355,14 @@ public override ICaseDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -340,7 +374,14 @@ public override ICaseDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -352,7 +393,14 @@ public override ICaseDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -366,12 +414,18 @@ public override ICaseDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -387,12 +441,18 @@ public override ICaseDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -400,6 +460,10 @@ public override ICaseDefinition Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading CaseDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -449,6 +513,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "CaseDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -542,6 +608,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -558,6 +628,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -620,7 +694,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -632,7 +713,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -644,7 +732,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -656,7 +751,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -668,7 +770,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -682,12 +791,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -703,12 +818,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -716,6 +837,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading CaseDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CaseUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CaseUsageReader.cs index bb080006c..6340e20ec 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CaseUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CaseUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class CaseUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public CaseUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public CaseUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "CaseUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override ICaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading CaseUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "CaseUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading CaseUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ClassReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ClassReader.cs index c1758bcd4..3733410fa 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ClassReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ClassReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -40,6 +41,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -64,7 +66,8 @@ public class ClassReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ClassReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ClassReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -110,6 +113,8 @@ public override IClass Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Class", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -183,6 +188,10 @@ public override IClass Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -199,6 +208,10 @@ public override IClass Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -261,7 +274,14 @@ public override IClass Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -273,7 +293,14 @@ public override IClass Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -285,7 +312,14 @@ public override IClass Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -299,12 +333,18 @@ public override IClass Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -320,12 +360,18 @@ public override IClass Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -333,6 +379,10 @@ public override IClass Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Class at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -382,6 +432,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Class", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -455,6 +507,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -471,6 +527,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -533,7 +593,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -545,7 +612,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -557,7 +631,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -571,12 +652,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -592,12 +679,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -605,6 +698,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Class at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ClassifierReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ClassifierReader.cs index 186383511..2bf820e53 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ClassifierReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ClassifierReader.cs @@ -33,12 +33,14 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -63,7 +65,8 @@ public class ClassifierReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ClassifierReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ClassifierReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -109,6 +112,8 @@ public override IClassifier Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Classifier", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -182,6 +187,10 @@ public override IClassifier Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -198,6 +207,10 @@ public override IClassifier Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -260,7 +273,14 @@ public override IClassifier Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -272,7 +292,14 @@ public override IClassifier Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -284,7 +311,14 @@ public override IClassifier Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -298,12 +332,18 @@ public override IClassifier Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -319,12 +359,18 @@ public override IClassifier Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -332,6 +378,10 @@ public override IClassifier Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Classifier at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -381,6 +431,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Classifier", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -454,6 +506,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -470,6 +526,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -532,7 +592,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -544,7 +611,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -556,7 +630,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -570,12 +651,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -591,12 +678,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -604,6 +697,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Classifier at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CollectExpressionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CollectExpressionReader.cs index a79f620d2..a5dabe1d7 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CollectExpressionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CollectExpressionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class CollectExpressionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public CollectExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public CollectExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "CollectExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -282,6 +287,10 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -298,6 +307,10 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -348,7 +361,14 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -372,7 +392,14 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -384,7 +411,14 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -396,7 +430,14 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -408,7 +449,14 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -420,7 +468,14 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -432,7 +487,14 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -444,7 +506,14 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -456,7 +525,14 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -468,7 +544,14 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -480,7 +563,14 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -492,7 +582,14 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -518,12 +615,18 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -539,12 +642,18 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -552,6 +661,10 @@ public override ICollectExpression Read(XmlReader xmiReader, Uri currentLocation break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading CollectExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -601,6 +714,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "CollectExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -629,7 +744,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -771,6 +886,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -787,6 +906,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -837,7 +960,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -861,7 +991,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -873,7 +1010,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -885,7 +1029,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -897,7 +1048,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -909,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -921,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -933,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -945,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -957,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -969,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -981,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1007,12 +1214,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1028,12 +1241,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1041,6 +1260,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading CollectExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CommentReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CommentReader.cs index 170e4edf9..63b2e39b8 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CommentReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CommentReader.cs @@ -33,9 +33,11 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -60,7 +62,8 @@ public class CommentReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public CommentReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public CommentReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -106,6 +109,8 @@ public override IComment Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Comment", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -173,6 +178,10 @@ public override IComment Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -189,6 +198,10 @@ public override IComment Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -263,7 +276,14 @@ public override IComment Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -289,12 +309,18 @@ public override IComment Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -310,12 +336,18 @@ public override IComment Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -323,6 +355,10 @@ public override IComment Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Comment at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -372,6 +408,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Comment", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -439,6 +477,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -455,6 +497,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -529,7 +575,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -555,12 +608,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +635,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -589,6 +654,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Comment at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConcernDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConcernDefinitionReader.cs index 6c1d6c156..827d08f30 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConcernDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConcernDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -63,6 +64,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -87,7 +89,8 @@ public class ConcernDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ConcernDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ConcernDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -133,6 +136,8 @@ public override IConcernDefinition Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConcernDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -219,6 +224,10 @@ public override IConcernDefinition Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -235,6 +244,10 @@ public override IConcernDefinition Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var reqIdXmlAttribute = xmiReader.GetAttribute("reqId"); @@ -292,7 +305,14 @@ public override IConcernDefinition Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -304,7 +324,14 @@ public override IConcernDefinition Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -316,7 +343,14 @@ public override IConcernDefinition Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -328,7 +362,14 @@ public override IConcernDefinition Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -340,7 +381,14 @@ public override IConcernDefinition Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -354,12 +402,18 @@ public override IConcernDefinition Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -375,12 +429,18 @@ public override IConcernDefinition Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -400,6 +460,10 @@ public override IConcernDefinition Read(XmlReader xmiReader, Uri currentLocation break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConcernDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -449,6 +513,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConcernDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -535,6 +601,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -551,6 +621,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var reqIdXmlAttribute = xmiReader.GetAttribute("reqId"); @@ -608,7 +682,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -620,7 +701,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -632,7 +720,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -644,7 +739,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -656,7 +758,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -670,12 +779,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -691,12 +806,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -716,6 +837,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConcernDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConcernUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConcernUsageReader.cs index 673877970..dfc817ccf 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConcernUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConcernUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class ConcernUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ConcernUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ConcernUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConcernUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -157,7 +162,7 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -302,6 +307,10 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -318,13 +327,17 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -373,7 +386,14 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -397,7 +417,14 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -409,7 +436,14 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -421,7 +455,14 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -433,7 +474,14 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -445,7 +493,14 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -457,7 +512,14 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -469,7 +531,14 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -481,7 +550,14 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -493,7 +569,14 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -505,7 +588,14 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -517,7 +607,14 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -529,7 +626,14 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -543,12 +647,18 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -564,12 +674,18 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -583,7 +699,14 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; @@ -601,6 +724,10 @@ public override IConcernUsage Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConcernUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConcernUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -671,7 +800,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -816,6 +945,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -832,13 +965,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -887,7 +1024,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -911,7 +1055,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -923,7 +1074,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -935,7 +1093,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -947,7 +1112,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -959,7 +1131,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -971,7 +1150,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -983,7 +1169,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -995,7 +1188,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1007,7 +1207,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1019,7 +1226,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1031,7 +1245,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1043,7 +1264,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1057,12 +1285,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1078,12 +1312,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1097,7 +1337,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; @@ -1115,6 +1362,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConcernUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConjugatedPortDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConjugatedPortDefinitionReader.cs index d7788f8bf..f7703d610 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConjugatedPortDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConjugatedPortDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -61,6 +62,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -85,7 +87,8 @@ public class ConjugatedPortDefinitionReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public ConjugatedPortDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ConjugatedPortDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -131,6 +134,8 @@ public override IConjugatedPortDefinition Read(XmlReader xmiReader, Uri currentL this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConjugatedPortDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -224,6 +229,10 @@ public override IConjugatedPortDefinition Read(XmlReader xmiReader, Uri currentL { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -240,6 +249,10 @@ public override IConjugatedPortDefinition Read(XmlReader xmiReader, Uri currentL { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -302,7 +315,14 @@ public override IConjugatedPortDefinition Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -314,7 +334,14 @@ public override IConjugatedPortDefinition Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -326,7 +353,14 @@ public override IConjugatedPortDefinition Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -338,7 +372,14 @@ public override IConjugatedPortDefinition Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -350,7 +391,14 @@ public override IConjugatedPortDefinition Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -364,12 +412,18 @@ public override IConjugatedPortDefinition Read(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -385,12 +439,18 @@ public override IConjugatedPortDefinition Read(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -398,6 +458,10 @@ public override IConjugatedPortDefinition Read(XmlReader xmiReader, Uri currentL break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConjugatedPortDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -447,6 +511,8 @@ public override async Task ReadAsync(XmlReader xmiRea this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConjugatedPortDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -540,6 +606,10 @@ public override async Task ReadAsync(XmlReader xmiRea { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -556,6 +626,10 @@ public override async Task ReadAsync(XmlReader xmiRea { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -618,7 +692,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -630,7 +711,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -642,7 +730,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -654,7 +749,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -666,7 +768,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -680,12 +789,18 @@ public override async Task ReadAsync(XmlReader xmiRea { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -701,12 +816,18 @@ public override async Task ReadAsync(XmlReader xmiRea { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -714,6 +835,10 @@ public override async Task ReadAsync(XmlReader xmiRea break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConjugatedPortDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConjugatedPortTypingReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConjugatedPortTypingReader.cs index 4b2c6b65c..36640d8d1 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConjugatedPortTypingReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConjugatedPortTypingReader.cs @@ -33,12 +33,14 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -63,7 +65,8 @@ public class ConjugatedPortTypingReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ConjugatedPortTypingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ConjugatedPortTypingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -109,6 +112,8 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConjugatedPortTyping", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -127,6 +132,10 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedPortDefinition", conjugatedPortDefinitionXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'conjugatedPortDefinition' on element {ElementId}", conjugatedPortDefinitionXmlAttribute, poco.Id); + } } var declaredNameXmlAttribute = xmiReader.GetAttribute("declaredName"); @@ -182,6 +191,10 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -202,6 +215,10 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -218,6 +235,10 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -228,6 +249,10 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var typedFeatureXmlAttribute = xmiReader.GetAttribute("typedFeature"); @@ -238,6 +263,10 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'typedFeature' on element {ElementId}", typedFeatureXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -266,12 +295,18 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var conjugatedPortDefinitionId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedPortDefinition", conjugatedPortDefinitionId); + if (Guid.TryParse(hrefSplit[1], out var conjugatedPortDefinitionId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedPortDefinition", conjugatedPortDefinitionId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'conjugatedPortDefinition' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var conjugatedPortDefinitionValue = (IConjugatedPortDefinition)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var conjugatedPortDefinitionValue = (IConjugatedPortDefinition)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ConjugatedPortDefinition = conjugatedPortDefinitionValue; } @@ -321,7 +356,14 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -333,7 +375,14 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -347,12 +396,18 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -368,12 +423,18 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -389,12 +450,18 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -410,12 +477,18 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -431,12 +504,18 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var typedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var typedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'typedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var typedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var typedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.TypedFeature = typedFeatureValue; } @@ -444,6 +523,10 @@ public override IConjugatedPortTyping Read(XmlReader xmiReader, Uri currentLocat break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConjugatedPortTyping at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -493,6 +576,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConjugatedPortTyping", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -511,6 +596,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedPortDefinition", conjugatedPortDefinitionXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'conjugatedPortDefinition' on element {ElementId}", conjugatedPortDefinitionXmlAttribute, poco.Id); + } } var declaredNameXmlAttribute = xmiReader.GetAttribute("declaredName"); @@ -566,6 +655,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -586,6 +679,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -602,6 +699,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -612,6 +713,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var typedFeatureXmlAttribute = xmiReader.GetAttribute("typedFeature"); @@ -622,6 +727,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'typedFeature' on element {ElementId}", typedFeatureXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -650,12 +759,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var conjugatedPortDefinitionId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedPortDefinition", conjugatedPortDefinitionId); + if (Guid.TryParse(hrefSplit[1], out var conjugatedPortDefinitionId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedPortDefinition", conjugatedPortDefinitionId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'conjugatedPortDefinition' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var conjugatedPortDefinitionValue = (IConjugatedPortDefinition)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var conjugatedPortDefinitionValue = (IConjugatedPortDefinition)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ConjugatedPortDefinition = conjugatedPortDefinitionValue; } @@ -705,7 +820,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -717,7 +839,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -731,12 +860,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -752,12 +887,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -773,12 +914,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -794,12 +941,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -815,12 +968,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var typedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var typedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'typedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var typedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var typedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.TypedFeature = typedFeatureValue; } @@ -828,6 +987,10 @@ public override async Task ReadAsync(XmlReader xmiReader, break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConjugatedPortTyping at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConjugationReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConjugationReader.cs index ab8533117..434662a93 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConjugationReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConjugationReader.cs @@ -33,10 +33,12 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -61,7 +63,8 @@ public class ConjugationReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ConjugationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ConjugationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -107,6 +110,8 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Conjugation", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -125,6 +130,10 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedType", conjugatedTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'conjugatedType' on element {ElementId}", conjugatedTypeXmlAttribute, poco.Id); + } } var declaredNameXmlAttribute = xmiReader.GetAttribute("declaredName"); @@ -176,6 +185,10 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "originalType", originalTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'originalType' on element {ElementId}", originalTypeXmlAttribute, poco.Id); + } } var ownedRelatedElementXmlAttribute = xmiReader.GetAttribute("ownedRelatedElement"); @@ -190,6 +203,10 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -210,6 +227,10 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -226,6 +247,10 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -236,6 +261,10 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -264,12 +293,18 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var conjugatedTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedType", conjugatedTypeId); + if (Guid.TryParse(hrefSplit[1], out var conjugatedTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedType", conjugatedTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'conjugatedType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var conjugatedTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var conjugatedTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ConjugatedType = conjugatedTypeValue; } @@ -319,7 +354,14 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -331,7 +373,14 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -345,12 +394,18 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var originalTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "originalType", originalTypeId); + if (Guid.TryParse(hrefSplit[1], out var originalTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "originalType", originalTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'originalType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var originalTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var originalTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.OriginalType = originalTypeValue; } @@ -366,12 +421,18 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -387,12 +448,18 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -408,12 +475,18 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -429,12 +502,18 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -442,6 +521,10 @@ public override IConjugation Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Conjugation at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -491,6 +574,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Conjugation", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -509,6 +594,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedType", conjugatedTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'conjugatedType' on element {ElementId}", conjugatedTypeXmlAttribute, poco.Id); + } } var declaredNameXmlAttribute = xmiReader.GetAttribute("declaredName"); @@ -560,6 +649,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "originalType", originalTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'originalType' on element {ElementId}", originalTypeXmlAttribute, poco.Id); + } } var ownedRelatedElementXmlAttribute = xmiReader.GetAttribute("ownedRelatedElement"); @@ -574,6 +667,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -594,6 +691,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -610,6 +711,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -620,6 +725,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -648,12 +757,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var conjugatedTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedType", conjugatedTypeId); + if (Guid.TryParse(hrefSplit[1], out var conjugatedTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedType", conjugatedTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'conjugatedType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var conjugatedTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var conjugatedTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ConjugatedType = conjugatedTypeValue; } @@ -703,7 +818,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -715,7 +837,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -729,12 +858,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var originalTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "originalType", originalTypeId); + if (Guid.TryParse(hrefSplit[1], out var originalTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "originalType", originalTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'originalType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var originalTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var originalTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.OriginalType = originalTypeValue; } @@ -750,12 +885,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -771,12 +912,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -792,12 +939,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -813,12 +966,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -826,6 +985,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Conjugation at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConnectionDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConnectionDefinitionReader.cs index 75004ee56..40806fc5c 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConnectionDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConnectionDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -62,6 +63,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -86,7 +88,8 @@ public class ConnectionDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ConnectionDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ConnectionDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -132,6 +135,8 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConnectionDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -235,6 +240,10 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -255,6 +264,10 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -271,6 +284,10 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -281,6 +298,10 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -343,7 +364,14 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -355,7 +383,14 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -367,7 +402,14 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -379,7 +421,14 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -391,7 +440,14 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -403,7 +459,14 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -417,12 +480,18 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -438,12 +507,18 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -459,12 +534,18 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -480,12 +561,18 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -493,6 +580,10 @@ public override IConnectionDefinition Read(XmlReader xmiReader, Uri currentLocat break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConnectionDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -542,6 +633,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConnectionDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -645,6 +738,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -665,6 +762,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -681,6 +782,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -691,6 +796,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -753,7 +862,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -765,7 +881,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -777,7 +900,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -789,7 +919,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -801,7 +938,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -813,7 +957,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -827,12 +978,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -848,12 +1005,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -869,12 +1032,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -890,12 +1059,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -903,6 +1078,10 @@ public override async Task ReadAsync(XmlReader xmiReader, break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConnectionDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConnectionUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConnectionUsageReader.cs index 05efa2ac8..47fd74d0e 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConnectionUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConnectionUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -67,6 +68,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -91,7 +93,8 @@ public class ConnectionUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ConnectionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ConnectionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -137,6 +140,8 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConnectionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -165,7 +170,7 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -320,6 +325,10 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -340,6 +349,10 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -356,6 +369,10 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -366,13 +383,17 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -426,7 +447,14 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -450,7 +478,14 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -462,7 +497,14 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -474,7 +516,14 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -486,7 +535,14 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -498,7 +554,14 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -510,7 +573,14 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -522,7 +592,14 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -534,7 +611,14 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -546,7 +630,14 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -558,7 +649,14 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -570,7 +668,14 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -582,7 +687,14 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -594,7 +706,14 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -608,12 +727,18 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -629,12 +754,18 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -650,12 +781,18 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -671,12 +808,18 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -690,12 +833,23 @@ public override IConnectionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConnectionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -745,6 +899,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConnectionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -773,7 +929,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -928,6 +1084,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -948,6 +1108,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -964,6 +1128,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -974,13 +1142,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -1034,7 +1206,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -1058,7 +1237,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -1070,7 +1256,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -1082,7 +1275,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -1094,7 +1294,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1106,7 +1313,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1118,7 +1332,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -1130,7 +1351,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1142,7 +1370,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1154,7 +1389,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1166,7 +1408,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1178,7 +1427,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1190,7 +1446,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1202,7 +1465,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1216,12 +1486,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -1237,12 +1513,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1258,12 +1540,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -1279,12 +1567,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1298,12 +1592,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConnectionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConnectorReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConnectorReader.cs index 85fd92756..864312aec 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConnectorReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConnectorReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -41,6 +42,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -65,7 +67,8 @@ public class ConnectorReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ConnectorReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ConnectorReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +114,8 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Connector", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -139,7 +144,7 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -284,6 +289,10 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -304,6 +313,10 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -320,6 +333,10 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -330,6 +347,10 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -380,7 +401,14 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -404,7 +432,14 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -416,7 +451,14 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -428,7 +470,14 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -440,7 +489,14 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -452,7 +508,14 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -464,7 +527,14 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -476,7 +546,14 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -488,7 +565,14 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -500,7 +584,14 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -512,7 +603,14 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -524,7 +622,14 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -536,7 +641,14 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -550,12 +662,18 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -571,12 +689,18 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -592,12 +716,18 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -613,12 +743,18 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -626,6 +762,10 @@ public override IConnector Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Connector at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -675,6 +815,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Connector", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -703,7 +845,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -848,6 +990,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -868,6 +1014,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -884,6 +1034,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -894,6 +1048,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -944,7 +1102,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -968,7 +1133,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -980,7 +1152,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -992,7 +1171,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -1004,7 +1190,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1016,7 +1209,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1028,7 +1228,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -1040,7 +1247,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1052,7 +1266,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1064,7 +1285,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1076,7 +1304,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1088,7 +1323,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1100,7 +1342,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1114,12 +1363,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -1135,12 +1390,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1156,12 +1417,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -1177,12 +1444,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1190,6 +1463,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Connector at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConstraintDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConstraintDefinitionReader.cs index af10e8709..7bd34e8e3 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConstraintDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConstraintDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -63,6 +64,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -87,7 +89,8 @@ public class ConstraintDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ConstraintDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ConstraintDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -133,6 +136,8 @@ public override IConstraintDefinition Read(XmlReader xmiReader, Uri currentLocat this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConstraintDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -226,6 +231,10 @@ public override IConstraintDefinition Read(XmlReader xmiReader, Uri currentLocat { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -242,6 +251,10 @@ public override IConstraintDefinition Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -304,7 +317,14 @@ public override IConstraintDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -316,7 +336,14 @@ public override IConstraintDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -328,7 +355,14 @@ public override IConstraintDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -340,7 +374,14 @@ public override IConstraintDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -352,7 +393,14 @@ public override IConstraintDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -366,12 +414,18 @@ public override IConstraintDefinition Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -387,12 +441,18 @@ public override IConstraintDefinition Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -400,6 +460,10 @@ public override IConstraintDefinition Read(XmlReader xmiReader, Uri currentLocat break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConstraintDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -449,6 +513,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConstraintDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -542,6 +608,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -558,6 +628,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -620,7 +694,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -632,7 +713,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -644,7 +732,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -656,7 +751,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -668,7 +770,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -682,12 +791,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -703,12 +818,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -716,6 +837,10 @@ public override async Task ReadAsync(XmlReader xmiReader, break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConstraintDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConstraintUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConstraintUsageReader.cs index 1b568b5f1..a71080d15 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConstraintUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConstraintUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class ConstraintUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ConstraintUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ConstraintUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConstraintUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override IConstraintUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConstraintUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConstraintUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConstraintUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConstructorExpressionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConstructorExpressionReader.cs index 72ab75a45..220345ab3 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConstructorExpressionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ConstructorExpressionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class ConstructorExpressionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ConstructorExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ConstructorExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConstructorExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -275,6 +280,10 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -291,6 +300,10 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -341,7 +354,14 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -365,7 +385,14 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -377,7 +404,14 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -389,7 +423,14 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -401,7 +442,14 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -413,7 +461,14 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -425,7 +480,14 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -437,7 +499,14 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -449,7 +518,14 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -461,7 +537,14 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -473,7 +556,14 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -485,7 +575,14 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -499,12 +596,18 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -520,12 +623,18 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -533,6 +642,10 @@ public override IConstructorExpression Read(XmlReader xmiReader, Uri currentLoca break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConstructorExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -582,6 +695,8 @@ public override async Task ReadAsync(XmlReader xmiReader this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ConstructorExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -610,7 +725,7 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -745,6 +860,10 @@ public override async Task ReadAsync(XmlReader xmiReader { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -761,6 +880,10 @@ public override async Task ReadAsync(XmlReader xmiReader { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -811,7 +934,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -835,7 +965,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -847,7 +984,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -859,7 +1003,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -871,7 +1022,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -883,7 +1041,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -895,7 +1060,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -907,7 +1079,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -919,7 +1098,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -931,7 +1117,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -943,7 +1136,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -955,7 +1155,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -969,12 +1176,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -990,12 +1203,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1003,6 +1222,10 @@ public override async Task ReadAsync(XmlReader xmiReader break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ConstructorExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CrossSubsettingReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CrossSubsettingReader.cs index da7f31b6b..7cda6c3e2 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CrossSubsettingReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/CrossSubsettingReader.cs @@ -33,11 +33,13 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -62,7 +64,8 @@ public class CrossSubsettingReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public CrossSubsettingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public CrossSubsettingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +111,8 @@ public override ICrossSubsetting Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "CrossSubsetting", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -126,6 +131,10 @@ public override ICrossSubsetting Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "crossedFeature", crossedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'crossedFeature' on element {ElementId}", crossedFeatureXmlAttribute, poco.Id); + } } var declaredNameXmlAttribute = xmiReader.GetAttribute("declaredName"); @@ -181,6 +190,10 @@ public override ICrossSubsetting Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -201,6 +214,10 @@ public override ICrossSubsetting Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -217,6 +234,10 @@ public override ICrossSubsetting Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -227,6 +248,10 @@ public override ICrossSubsetting Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -255,12 +280,18 @@ public override ICrossSubsetting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var crossedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "crossedFeature", crossedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var crossedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "crossedFeature", crossedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'crossedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var crossedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var crossedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.CrossedFeature = crossedFeatureValue; } @@ -310,7 +341,14 @@ public override ICrossSubsetting Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -322,7 +360,14 @@ public override ICrossSubsetting Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -336,12 +381,18 @@ public override ICrossSubsetting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -357,12 +408,18 @@ public override ICrossSubsetting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -378,12 +435,18 @@ public override ICrossSubsetting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -399,12 +462,18 @@ public override ICrossSubsetting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -412,6 +481,10 @@ public override ICrossSubsetting Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading CrossSubsetting at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -461,6 +534,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "CrossSubsetting", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -479,6 +554,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "crossedFeature", crossedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'crossedFeature' on element {ElementId}", crossedFeatureXmlAttribute, poco.Id); + } } var declaredNameXmlAttribute = xmiReader.GetAttribute("declaredName"); @@ -534,6 +613,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -554,6 +637,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -570,6 +657,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -580,6 +671,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -608,12 +703,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var crossedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "crossedFeature", crossedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var crossedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "crossedFeature", crossedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'crossedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var crossedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var crossedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.CrossedFeature = crossedFeatureValue; } @@ -663,7 +764,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -675,7 +783,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -689,12 +804,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -710,12 +831,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -731,12 +858,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -752,12 +885,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -765,6 +904,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading CrossSubsetting at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DataTypeReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DataTypeReader.cs index 9c78352ac..291e95ec6 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DataTypeReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DataTypeReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -40,6 +41,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.DataTypes; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -64,7 +66,8 @@ public class DataTypeReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public DataTypeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public DataTypeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -110,6 +113,8 @@ public override IDataType Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "DataType", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -183,6 +188,10 @@ public override IDataType Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -199,6 +208,10 @@ public override IDataType Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -261,7 +274,14 @@ public override IDataType Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -273,7 +293,14 @@ public override IDataType Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -285,7 +312,14 @@ public override IDataType Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -299,12 +333,18 @@ public override IDataType Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -320,12 +360,18 @@ public override IDataType Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -333,6 +379,10 @@ public override IDataType Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading DataType at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -382,6 +432,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "DataType", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -455,6 +507,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -471,6 +527,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -533,7 +593,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -545,7 +612,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -557,7 +631,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -571,12 +652,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -592,12 +679,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -605,6 +698,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading DataType at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DecisionNodeReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DecisionNodeReader.cs index 940e8818f..cb0331b16 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DecisionNodeReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DecisionNodeReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -65,6 +66,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -89,7 +91,8 @@ public class DecisionNodeReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public DecisionNodeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public DecisionNodeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -135,6 +138,8 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "DecisionNode", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -163,7 +168,7 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -308,6 +313,10 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -324,13 +333,17 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -384,7 +397,14 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -408,7 +428,14 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -420,7 +447,14 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -432,7 +466,14 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -444,7 +485,14 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -456,7 +504,14 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -468,7 +523,14 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -480,7 +542,14 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -492,7 +561,14 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -504,7 +580,14 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -516,7 +599,14 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -528,7 +618,14 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -540,7 +637,14 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -554,12 +658,18 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -575,12 +685,18 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -594,12 +710,23 @@ public override IDecisionNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading DecisionNode at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -649,6 +776,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "DecisionNode", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -677,7 +806,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -822,6 +951,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -838,13 +971,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -898,7 +1035,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -922,7 +1066,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -934,7 +1085,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -946,7 +1104,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -958,7 +1123,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -970,7 +1142,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -982,7 +1161,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -994,7 +1180,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1006,7 +1199,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1018,7 +1218,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1030,7 +1237,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1042,7 +1256,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1054,7 +1275,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1068,12 +1296,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1089,12 +1323,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1108,12 +1348,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading DecisionNode at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DefinitionReader.cs index 53c8c50e4..b7aec2179 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -61,6 +62,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -85,7 +87,8 @@ public class DefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public DefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public DefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -131,6 +134,8 @@ public override IDefinition Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Definition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -214,6 +219,10 @@ public override IDefinition Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -230,6 +239,10 @@ public override IDefinition Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -292,7 +305,14 @@ public override IDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -304,7 +324,14 @@ public override IDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -316,7 +343,14 @@ public override IDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -328,7 +362,14 @@ public override IDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -342,12 +383,18 @@ public override IDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -363,12 +410,18 @@ public override IDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -376,6 +429,10 @@ public override IDefinition Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Definition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -425,6 +482,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Definition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -508,6 +567,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -524,6 +587,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -586,7 +653,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -598,7 +672,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -610,7 +691,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -622,7 +710,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -636,12 +731,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -657,12 +758,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -670,6 +777,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Definition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DependencyReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DependencyReader.cs index 6de94ece1..cd8e94dc0 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DependencyReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DependencyReader.cs @@ -33,10 +33,12 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Dependencies; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -61,7 +63,8 @@ public class DependencyReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public DependencyReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public DependencyReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -107,6 +110,8 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Dependency", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -129,6 +134,10 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { clientXmlAttributeReferences.Add(clientXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'client' on element {ElementId}", clientXmlAttributeValue, poco.Id); + } } if (clientXmlAttributeReferences.Count != 0) @@ -190,6 +199,10 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -210,6 +223,10 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -226,6 +243,10 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -236,6 +257,10 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var supplierXmlAttribute = xmiReader.GetAttribute("supplier"); @@ -250,6 +275,10 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { supplierXmlAttributeReferences.Add(supplierXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'supplier' on element {ElementId}", supplierXmlAttributeValue, poco.Id); + } } if (supplierXmlAttributeReferences.Count != 0) @@ -284,12 +313,18 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var clientId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "client", clientId); + if (Guid.TryParse(hrefSplit[1], out var clientId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "client", clientId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'client' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var clientValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var clientValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Client.Add(clientValue); } @@ -339,7 +374,14 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -351,7 +393,14 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -365,12 +414,18 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -386,12 +441,18 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -407,12 +468,18 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -428,12 +495,18 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -449,12 +522,18 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var supplierId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "supplier", supplierId); + if (Guid.TryParse(hrefSplit[1], out var supplierId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "supplier", supplierId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'supplier' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var supplierValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var supplierValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Supplier.Add(supplierValue); } @@ -462,6 +541,10 @@ public override IDependency Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Dependency at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -511,6 +594,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Dependency", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -533,6 +618,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { clientXmlAttributeReferences.Add(clientXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'client' on element {ElementId}", clientXmlAttributeValue, poco.Id); + } } if (clientXmlAttributeReferences.Count != 0) @@ -594,6 +683,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -614,6 +707,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -630,6 +727,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -640,6 +741,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var supplierXmlAttribute = xmiReader.GetAttribute("supplier"); @@ -654,6 +759,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { supplierXmlAttributeReferences.Add(supplierXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'supplier' on element {ElementId}", supplierXmlAttributeValue, poco.Id); + } } if (supplierXmlAttributeReferences.Count != 0) @@ -688,12 +797,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var clientId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "client", clientId); + if (Guid.TryParse(hrefSplit[1], out var clientId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "client", clientId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'client' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var clientValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var clientValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Client.Add(clientValue); } @@ -743,7 +858,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -755,7 +877,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -769,12 +898,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -790,12 +925,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -811,12 +952,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -832,12 +979,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -853,12 +1006,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var supplierId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "supplier", supplierId); + if (Guid.TryParse(hrefSplit[1], out var supplierId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "supplier", supplierId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'supplier' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var supplierValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var supplierValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Supplier.Add(supplierValue); } @@ -866,6 +1025,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Dependency at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DifferencingReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DifferencingReader.cs index dd2bd3efe..0da16bfdf 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DifferencingReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DifferencingReader.cs @@ -33,10 +33,12 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -61,7 +63,8 @@ public class DifferencingReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public DifferencingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public DifferencingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -107,6 +110,8 @@ public override IDifferencing Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Differencing", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -139,6 +144,10 @@ public override IDifferencing Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "differencingType", differencingTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'differencingType' on element {ElementId}", differencingTypeXmlAttribute, poco.Id); + } } var elementIdXmlAttribute = xmiReader.GetAttribute("elementId"); @@ -180,6 +189,10 @@ public override IDifferencing Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -200,6 +213,10 @@ public override IDifferencing Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -216,6 +233,10 @@ public override IDifferencing Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -226,6 +247,10 @@ public override IDifferencing Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -278,12 +303,18 @@ public override IDifferencing Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var differencingTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "differencingType", differencingTypeId); + if (Guid.TryParse(hrefSplit[1], out var differencingTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "differencingType", differencingTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'differencingType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var differencingTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var differencingTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.DifferencingType = differencingTypeValue; } @@ -309,7 +340,14 @@ public override IDifferencing Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -321,7 +359,14 @@ public override IDifferencing Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -335,12 +380,18 @@ public override IDifferencing Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -356,12 +407,18 @@ public override IDifferencing Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -377,12 +434,18 @@ public override IDifferencing Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -398,12 +461,18 @@ public override IDifferencing Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -411,6 +480,10 @@ public override IDifferencing Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Differencing at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -460,6 +533,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Differencing", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -492,6 +567,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "differencingType", differencingTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'differencingType' on element {ElementId}", differencingTypeXmlAttribute, poco.Id); + } } var elementIdXmlAttribute = xmiReader.GetAttribute("elementId"); @@ -533,6 +612,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -553,6 +636,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -569,6 +656,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -579,6 +670,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -631,12 +726,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var differencingTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "differencingType", differencingTypeId); + if (Guid.TryParse(hrefSplit[1], out var differencingTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "differencingType", differencingTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'differencingType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var differencingTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var differencingTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.DifferencingType = differencingTypeValue; } @@ -662,7 +763,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -674,7 +782,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -688,12 +803,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -709,12 +830,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -730,12 +857,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -751,12 +884,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -764,6 +903,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Differencing at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DisjoiningReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DisjoiningReader.cs index 1a242070d..ff2824fbe 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DisjoiningReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DisjoiningReader.cs @@ -33,10 +33,12 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -61,7 +63,8 @@ public class DisjoiningReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public DisjoiningReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public DisjoiningReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -107,6 +110,8 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Disjoining", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -139,6 +144,10 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "disjoiningType", disjoiningTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'disjoiningType' on element {ElementId}", disjoiningTypeXmlAttribute, poco.Id); + } } var elementIdXmlAttribute = xmiReader.GetAttribute("elementId"); @@ -180,6 +189,10 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -200,6 +213,10 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -216,6 +233,10 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -226,6 +247,10 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var typeDisjoinedXmlAttribute = xmiReader.GetAttribute("typeDisjoined"); @@ -236,6 +261,10 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typeDisjoined", typeDisjoinedXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'typeDisjoined' on element {ElementId}", typeDisjoinedXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -288,12 +317,18 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var disjoiningTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "disjoiningType", disjoiningTypeId); + if (Guid.TryParse(hrefSplit[1], out var disjoiningTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "disjoiningType", disjoiningTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'disjoiningType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var disjoiningTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var disjoiningTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.DisjoiningType = disjoiningTypeValue; } @@ -319,7 +354,14 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -331,7 +373,14 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -345,12 +394,18 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -366,12 +421,18 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -387,12 +448,18 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -408,12 +475,18 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -429,12 +502,18 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var typeDisjoinedId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typeDisjoined", typeDisjoinedId); + if (Guid.TryParse(hrefSplit[1], out var typeDisjoinedId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typeDisjoined", typeDisjoinedId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'typeDisjoined' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var typeDisjoinedValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var typeDisjoinedValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.TypeDisjoined = typeDisjoinedValue; } @@ -442,6 +521,10 @@ public override IDisjoining Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Disjoining at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -491,6 +574,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Disjoining", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -523,6 +608,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "disjoiningType", disjoiningTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'disjoiningType' on element {ElementId}", disjoiningTypeXmlAttribute, poco.Id); + } } var elementIdXmlAttribute = xmiReader.GetAttribute("elementId"); @@ -564,6 +653,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -584,6 +677,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -600,6 +697,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -610,6 +711,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var typeDisjoinedXmlAttribute = xmiReader.GetAttribute("typeDisjoined"); @@ -620,6 +725,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typeDisjoined", typeDisjoinedXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'typeDisjoined' on element {ElementId}", typeDisjoinedXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -672,12 +781,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var disjoiningTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "disjoiningType", disjoiningTypeId); + if (Guid.TryParse(hrefSplit[1], out var disjoiningTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "disjoiningType", disjoiningTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'disjoiningType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var disjoiningTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var disjoiningTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.DisjoiningType = disjoiningTypeValue; } @@ -703,7 +818,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -715,7 +837,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -729,12 +858,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -750,12 +885,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -771,12 +912,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -792,12 +939,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -813,12 +966,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var typeDisjoinedId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typeDisjoined", typeDisjoinedId); + if (Guid.TryParse(hrefSplit[1], out var typeDisjoinedId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typeDisjoined", typeDisjoinedId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'typeDisjoined' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var typeDisjoinedValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var typeDisjoinedValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.TypeDisjoined = typeDisjoinedValue; } @@ -826,6 +985,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Disjoining at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DocumentationReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DocumentationReader.cs index bc6543019..3c9e019c0 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DocumentationReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/DocumentationReader.cs @@ -33,9 +33,11 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -60,7 +62,8 @@ public class DocumentationReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public DocumentationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public DocumentationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -106,6 +109,8 @@ public override IDocumentation Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Documentation", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -173,6 +178,10 @@ public override IDocumentation Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -189,6 +198,10 @@ public override IDocumentation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -263,7 +276,14 @@ public override IDocumentation Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -289,12 +309,18 @@ public override IDocumentation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -310,12 +336,18 @@ public override IDocumentation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -323,6 +355,10 @@ public override IDocumentation Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Documentation at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -372,6 +408,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Documentation", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -439,6 +477,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -455,6 +497,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -529,7 +575,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -555,12 +608,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +635,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -589,6 +654,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Documentation at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ElementFilterMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ElementFilterMembershipReader.cs index c3128110f..90f7ef2a3 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ElementFilterMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ElementFilterMembershipReader.cs @@ -33,12 +33,14 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Functions; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Packages; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -63,7 +65,8 @@ public class ElementFilterMembershipReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public ElementFilterMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ElementFilterMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -109,6 +112,8 @@ public override IElementFilterMembership Read(XmlReader xmiReader, Uri currentLo this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ElementFilterMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -172,6 +177,10 @@ public override IElementFilterMembership Read(XmlReader xmiReader, Uri currentLo { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -192,6 +201,10 @@ public override IElementFilterMembership Read(XmlReader xmiReader, Uri currentLo { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -208,6 +221,10 @@ public override IElementFilterMembership Read(XmlReader xmiReader, Uri currentLo { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -218,13 +235,17 @@ public override IElementFilterMembership Read(XmlReader xmiReader, Uri currentLo { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -290,7 +311,14 @@ public override IElementFilterMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -302,7 +330,14 @@ public override IElementFilterMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -316,12 +351,18 @@ public override IElementFilterMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -337,12 +378,18 @@ public override IElementFilterMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -358,12 +405,18 @@ public override IElementFilterMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -379,12 +432,18 @@ public override IElementFilterMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -398,12 +457,23 @@ public override IElementFilterMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ElementFilterMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -453,6 +523,8 @@ public override async Task ReadAsync(XmlReader xmiRead this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ElementFilterMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -516,6 +588,10 @@ public override async Task ReadAsync(XmlReader xmiRead { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -536,6 +612,10 @@ public override async Task ReadAsync(XmlReader xmiRead { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -552,6 +632,10 @@ public override async Task ReadAsync(XmlReader xmiRead { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -562,13 +646,17 @@ public override async Task ReadAsync(XmlReader xmiRead { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -634,7 +722,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -646,7 +741,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -660,12 +762,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -681,12 +789,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -702,12 +816,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -723,12 +843,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -742,12 +868,23 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ElementFilterMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EndFeatureMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EndFeatureMembershipReader.cs index 9df6c142f..54b039cf9 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EndFeatureMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EndFeatureMembershipReader.cs @@ -33,12 +33,14 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -63,7 +65,8 @@ public class EndFeatureMembershipReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public EndFeatureMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public EndFeatureMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -109,6 +112,8 @@ public override IEndFeatureMembership Read(XmlReader xmiReader, Uri currentLocat this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "EndFeatureMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -172,6 +177,10 @@ public override IEndFeatureMembership Read(XmlReader xmiReader, Uri currentLocat { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -192,6 +201,10 @@ public override IEndFeatureMembership Read(XmlReader xmiReader, Uri currentLocat { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -208,6 +221,10 @@ public override IEndFeatureMembership Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -218,13 +235,17 @@ public override IEndFeatureMembership Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -290,7 +311,14 @@ public override IEndFeatureMembership Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -302,7 +330,14 @@ public override IEndFeatureMembership Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -316,12 +351,18 @@ public override IEndFeatureMembership Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -337,12 +378,18 @@ public override IEndFeatureMembership Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -358,12 +405,18 @@ public override IEndFeatureMembership Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -379,12 +432,18 @@ public override IEndFeatureMembership Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -398,12 +457,23 @@ public override IEndFeatureMembership Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading EndFeatureMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -453,6 +523,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "EndFeatureMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -516,6 +588,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -536,6 +612,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -552,6 +632,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -562,13 +646,17 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -634,7 +722,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -646,7 +741,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -660,12 +762,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -681,12 +789,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -702,12 +816,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -723,12 +843,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -742,12 +868,23 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading EndFeatureMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EnumerationDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EnumerationDefinitionReader.cs index 1abcad16c..2cc664a97 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EnumerationDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EnumerationDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -61,6 +62,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -85,7 +87,8 @@ public class EnumerationDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public EnumerationDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public EnumerationDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -131,6 +134,8 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "EnumerationDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -214,6 +219,10 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -230,6 +239,10 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -292,7 +305,14 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -304,7 +324,14 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -316,7 +343,14 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -328,7 +362,14 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -342,12 +383,18 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -363,12 +410,18 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -376,6 +429,10 @@ public override IEnumerationDefinition Read(XmlReader xmiReader, Uri currentLoca break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading EnumerationDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -425,6 +482,8 @@ public override async Task ReadAsync(XmlReader xmiReader this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "EnumerationDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -508,6 +567,10 @@ public override async Task ReadAsync(XmlReader xmiReader { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -524,6 +587,10 @@ public override async Task ReadAsync(XmlReader xmiReader { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -586,7 +653,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -598,7 +672,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -610,7 +691,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -622,7 +710,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -636,12 +731,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -657,12 +758,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -670,6 +777,10 @@ public override async Task ReadAsync(XmlReader xmiReader break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading EnumerationDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EnumerationUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EnumerationUsageReader.cs index 745511aed..16fc1e917 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EnumerationUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EnumerationUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; @@ -63,6 +64,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -87,7 +89,8 @@ public class EnumerationUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public EnumerationUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public EnumerationUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -133,6 +136,8 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "EnumerationUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -161,7 +166,7 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -296,6 +301,10 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -312,6 +321,10 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -362,7 +375,14 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -386,7 +406,14 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -398,7 +425,14 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -410,7 +444,14 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -422,7 +463,14 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -434,7 +482,14 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -446,7 +501,14 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -458,7 +520,14 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -470,7 +539,14 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -482,7 +558,14 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -494,7 +577,14 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -506,7 +596,14 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -520,12 +617,18 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -541,12 +644,18 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -554,6 +663,10 @@ public override IEnumerationUsage Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading EnumerationUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -603,6 +716,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "EnumerationUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -631,7 +746,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -766,6 +881,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -782,6 +901,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -832,7 +955,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -856,7 +986,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -868,7 +1005,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -880,7 +1024,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -892,7 +1043,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -904,7 +1062,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -916,7 +1081,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -928,7 +1100,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -940,7 +1119,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -952,7 +1138,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -964,7 +1157,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -976,7 +1176,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -990,12 +1197,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1011,12 +1224,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1024,6 +1243,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading EnumerationUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EventOccurrenceUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EventOccurrenceUsageReader.cs index 9f2a55a8e..eda61a6f7 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EventOccurrenceUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/EventOccurrenceUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -64,6 +65,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -88,7 +90,8 @@ public class EventOccurrenceUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public EventOccurrenceUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public EventOccurrenceUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -134,6 +137,8 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "EventOccurrenceUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -162,7 +167,7 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -307,6 +312,10 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -323,13 +332,17 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -383,7 +396,14 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -407,7 +427,14 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -419,7 +446,14 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -431,7 +465,14 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -443,7 +484,14 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -455,7 +503,14 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -467,7 +522,14 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -479,7 +541,14 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -491,7 +560,14 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -503,7 +579,14 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -515,7 +598,14 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -527,7 +617,14 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -539,7 +636,14 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -553,12 +657,18 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -574,12 +684,18 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -593,12 +709,23 @@ public override IEventOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading EventOccurrenceUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -648,6 +775,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "EventOccurrenceUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -676,7 +805,7 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -821,6 +950,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -837,13 +970,17 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -897,7 +1034,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -921,7 +1065,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -933,7 +1084,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -945,7 +1103,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -957,7 +1122,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -969,7 +1141,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -981,7 +1160,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -993,7 +1179,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1005,7 +1198,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1017,7 +1217,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1029,7 +1236,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1041,7 +1255,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1053,7 +1274,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1067,12 +1295,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1088,12 +1322,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1107,12 +1347,23 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading EventOccurrenceUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ExhibitStateUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ExhibitStateUsageReader.cs index 4ce391bed..3c84e9398 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ExhibitStateUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ExhibitStateUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -65,6 +66,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -89,7 +91,8 @@ public class ExhibitStateUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ExhibitStateUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ExhibitStateUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -135,6 +138,8 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ExhibitStateUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -163,7 +168,7 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -318,6 +323,10 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -334,13 +343,17 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -394,7 +407,14 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -418,7 +438,14 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -430,7 +457,14 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -442,7 +476,14 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -454,7 +495,14 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -466,7 +514,14 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -478,7 +533,14 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -490,7 +552,14 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -502,7 +571,14 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -514,7 +590,14 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isParallelValue)) { - poco.IsParallel = bool.Parse(isParallelValue); + if (bool.TryParse(isParallelValue, out var isParallelValueAsBool)) + { + poco.IsParallel = isParallelValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isParallel' on element {ElementId}", isParallelValue, poco.Id); + } } break; @@ -526,7 +609,14 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -538,7 +628,14 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -550,7 +647,14 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -562,7 +666,14 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -576,12 +687,18 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -597,12 +714,18 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -616,12 +739,23 @@ public override IExhibitStateUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ExhibitStateUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -671,6 +805,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ExhibitStateUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -699,7 +835,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -854,6 +990,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -870,13 +1010,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -930,7 +1074,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -954,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -966,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -978,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -990,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1002,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1014,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1026,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1038,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1050,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isParallelValue)) { - poco.IsParallel = bool.Parse(isParallelValue); + if (bool.TryParse(isParallelValue, out var isParallelValueAsBool)) + { + poco.IsParallel = isParallelValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isParallel' on element {ElementId}", isParallelValue, poco.Id); + } } break; @@ -1062,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1074,7 +1295,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1086,7 +1314,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1098,7 +1333,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1112,12 +1354,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1133,12 +1381,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1152,12 +1406,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ExhibitStateUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ExpressionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ExpressionReader.cs index 853b894f7..11c659c3a 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ExpressionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ExpressionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -41,6 +42,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -65,7 +67,8 @@ public class ExpressionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +114,8 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Expression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -139,7 +144,7 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -274,6 +279,10 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -290,6 +299,10 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -340,7 +353,14 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -364,7 +384,14 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -376,7 +403,14 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -388,7 +422,14 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -400,7 +441,14 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -412,7 +460,14 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -424,7 +479,14 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -436,7 +498,14 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -448,7 +517,14 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -460,7 +536,14 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -472,7 +555,14 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -484,7 +574,14 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -498,12 +595,18 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -519,12 +622,18 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -532,6 +641,10 @@ public override IExpression Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Expression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -581,6 +694,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Expression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -609,7 +724,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -744,6 +859,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -760,6 +879,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -810,7 +933,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -834,7 +964,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -846,7 +983,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -858,7 +1002,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -870,7 +1021,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -882,7 +1040,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -894,7 +1059,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -906,7 +1078,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -918,7 +1097,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -930,7 +1116,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -942,7 +1135,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -954,7 +1154,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -968,12 +1175,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -989,12 +1202,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1002,6 +1221,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Expression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureChainExpressionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureChainExpressionReader.cs index 647fd40b2..4fb7128e1 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureChainExpressionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureChainExpressionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class FeatureChainExpressionReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public FeatureChainExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FeatureChainExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureChainExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -282,6 +287,10 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -298,6 +307,10 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -348,7 +361,14 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -372,7 +392,14 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -384,7 +411,14 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -396,7 +430,14 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -408,7 +449,14 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -420,7 +468,14 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -432,7 +487,14 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -444,7 +506,14 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -456,7 +525,14 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -468,7 +544,14 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -480,7 +563,14 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -492,7 +582,14 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -518,12 +615,18 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -539,12 +642,18 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -552,6 +661,10 @@ public override IFeatureChainExpression Read(XmlReader xmiReader, Uri currentLoc break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureChainExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -601,6 +714,8 @@ public override async Task ReadAsync(XmlReader xmiReade this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureChainExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -629,7 +744,7 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -771,6 +886,10 @@ public override async Task ReadAsync(XmlReader xmiReade { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -787,6 +906,10 @@ public override async Task ReadAsync(XmlReader xmiReade { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -837,7 +960,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -861,7 +991,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -873,7 +1010,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -885,7 +1029,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -897,7 +1048,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -909,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -921,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -933,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -945,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -957,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -969,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -981,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReade if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1007,12 +1214,18 @@ public override async Task ReadAsync(XmlReader xmiReade { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1028,12 +1241,18 @@ public override async Task ReadAsync(XmlReader xmiReade { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1041,6 +1260,10 @@ public override async Task ReadAsync(XmlReader xmiReade break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureChainExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureChainingReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureChainingReader.cs index 90e8e7f9d..a3eba6c1e 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureChainingReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureChainingReader.cs @@ -33,10 +33,12 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -61,7 +63,8 @@ public class FeatureChainingReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public FeatureChainingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FeatureChainingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -107,6 +110,8 @@ public override IFeatureChaining Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureChaining", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -125,6 +130,10 @@ public override IFeatureChaining Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "chainingFeature", chainingFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'chainingFeature' on element {ElementId}", chainingFeatureXmlAttribute, poco.Id); + } } var declaredNameXmlAttribute = xmiReader.GetAttribute("declaredName"); @@ -180,6 +189,10 @@ public override IFeatureChaining Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -200,6 +213,10 @@ public override IFeatureChaining Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -216,6 +233,10 @@ public override IFeatureChaining Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -226,6 +247,10 @@ public override IFeatureChaining Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -254,12 +279,18 @@ public override IFeatureChaining Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var chainingFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "chainingFeature", chainingFeatureId); + if (Guid.TryParse(hrefSplit[1], out var chainingFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "chainingFeature", chainingFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'chainingFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var chainingFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var chainingFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ChainingFeature = chainingFeatureValue; } @@ -309,7 +340,14 @@ public override IFeatureChaining Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -321,7 +359,14 @@ public override IFeatureChaining Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -335,12 +380,18 @@ public override IFeatureChaining Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -356,12 +407,18 @@ public override IFeatureChaining Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -377,12 +434,18 @@ public override IFeatureChaining Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -398,12 +461,18 @@ public override IFeatureChaining Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -411,6 +480,10 @@ public override IFeatureChaining Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureChaining at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -460,6 +533,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureChaining", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -478,6 +553,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "chainingFeature", chainingFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'chainingFeature' on element {ElementId}", chainingFeatureXmlAttribute, poco.Id); + } } var declaredNameXmlAttribute = xmiReader.GetAttribute("declaredName"); @@ -533,6 +612,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -553,6 +636,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -569,6 +656,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -579,6 +670,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -607,12 +702,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var chainingFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "chainingFeature", chainingFeatureId); + if (Guid.TryParse(hrefSplit[1], out var chainingFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "chainingFeature", chainingFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'chainingFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var chainingFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var chainingFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ChainingFeature = chainingFeatureValue; } @@ -662,7 +763,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -674,7 +782,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -688,12 +803,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -709,12 +830,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -730,12 +857,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -751,12 +884,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -764,6 +903,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureChaining at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureInvertingReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureInvertingReader.cs index 0309ab431..26fe15119 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureInvertingReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureInvertingReader.cs @@ -33,10 +33,12 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -61,7 +63,8 @@ public class FeatureInvertingReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public FeatureInvertingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FeatureInvertingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -107,6 +110,8 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureInverting", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -146,6 +151,10 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featureInverted", featureInvertedXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'featureInverted' on element {ElementId}", featureInvertedXmlAttribute, poco.Id); + } } var invertingFeatureXmlAttribute = xmiReader.GetAttribute("invertingFeature"); @@ -156,6 +165,10 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "invertingFeature", invertingFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'invertingFeature' on element {ElementId}", invertingFeatureXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -190,6 +203,10 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -210,6 +227,10 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -226,6 +247,10 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -236,6 +261,10 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -300,12 +329,18 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var featureInvertedId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featureInverted", featureInvertedId); + if (Guid.TryParse(hrefSplit[1], out var featureInvertedId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featureInverted", featureInvertedId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'featureInverted' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var featureInvertedValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var featureInvertedValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.FeatureInverted = featureInvertedValue; } @@ -321,12 +356,18 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var invertingFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "invertingFeature", invertingFeatureId); + if (Guid.TryParse(hrefSplit[1], out var invertingFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "invertingFeature", invertingFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'invertingFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var invertingFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var invertingFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.InvertingFeature = invertingFeatureValue; } @@ -340,7 +381,14 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -352,7 +400,14 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -366,12 +421,18 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -387,12 +448,18 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -408,12 +475,18 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -429,12 +502,18 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -442,6 +521,10 @@ public override IFeatureInverting Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureInverting at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -491,6 +574,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureInverting", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -530,6 +615,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featureInverted", featureInvertedXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'featureInverted' on element {ElementId}", featureInvertedXmlAttribute, poco.Id); + } } var invertingFeatureXmlAttribute = xmiReader.GetAttribute("invertingFeature"); @@ -540,6 +629,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "invertingFeature", invertingFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'invertingFeature' on element {ElementId}", invertingFeatureXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -574,6 +667,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -594,6 +691,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -610,6 +711,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -620,6 +725,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -684,12 +793,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var featureInvertedId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featureInverted", featureInvertedId); + if (Guid.TryParse(hrefSplit[1], out var featureInvertedId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featureInverted", featureInvertedId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'featureInverted' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var featureInvertedValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var featureInvertedValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.FeatureInverted = featureInvertedValue; } @@ -705,12 +820,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var invertingFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "invertingFeature", invertingFeatureId); + if (Guid.TryParse(hrefSplit[1], out var invertingFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "invertingFeature", invertingFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'invertingFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var invertingFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var invertingFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.InvertingFeature = invertingFeatureValue; } @@ -724,7 +845,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -736,7 +864,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -750,12 +885,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -771,12 +912,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -792,12 +939,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -813,12 +966,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -826,6 +985,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureInverting at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureMembershipReader.cs index 6aae31a9d..176ea038e 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureMembershipReader.cs @@ -33,12 +33,14 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -63,7 +65,8 @@ public class FeatureMembershipReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public FeatureMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FeatureMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -109,6 +112,8 @@ public override IFeatureMembership Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -172,6 +177,10 @@ public override IFeatureMembership Read(XmlReader xmiReader, Uri currentLocation { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -192,6 +201,10 @@ public override IFeatureMembership Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -208,6 +221,10 @@ public override IFeatureMembership Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -218,13 +235,17 @@ public override IFeatureMembership Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -290,7 +311,14 @@ public override IFeatureMembership Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -302,7 +330,14 @@ public override IFeatureMembership Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -316,12 +351,18 @@ public override IFeatureMembership Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -337,12 +378,18 @@ public override IFeatureMembership Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -358,12 +405,18 @@ public override IFeatureMembership Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -379,12 +432,18 @@ public override IFeatureMembership Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -398,12 +457,23 @@ public override IFeatureMembership Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -453,6 +523,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -516,6 +588,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -536,6 +612,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -552,6 +632,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -562,13 +646,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -634,7 +722,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -646,7 +741,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -660,12 +762,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -681,12 +789,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -702,12 +816,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -723,12 +843,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -742,12 +868,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureReader.cs index dcf987af4..f655dbbe5 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureReader.cs @@ -33,12 +33,14 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -63,7 +65,8 @@ public class FeatureReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public FeatureReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FeatureReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -109,6 +112,8 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Feature", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -137,7 +142,7 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -272,6 +277,10 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -288,6 +297,10 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -338,7 +351,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -362,7 +382,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -374,7 +401,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -386,7 +420,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -398,7 +439,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -410,7 +458,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -422,7 +477,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -434,7 +496,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -446,7 +515,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -458,7 +534,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -470,7 +553,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -482,7 +572,14 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -496,12 +593,18 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -517,12 +620,18 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -530,6 +639,10 @@ public override IFeature Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Feature at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -579,6 +692,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Feature", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -607,7 +722,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -742,6 +857,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -758,6 +877,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -808,7 +931,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -832,7 +962,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -844,7 +981,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -856,7 +1000,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -868,7 +1019,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -880,7 +1038,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -892,7 +1057,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -904,7 +1076,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -916,7 +1095,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -928,7 +1114,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -940,7 +1133,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -952,7 +1152,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -966,12 +1173,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -987,12 +1200,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1000,6 +1219,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Feature at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureReferenceExpressionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureReferenceExpressionReader.cs index 1ee370c4e..9249aab27 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureReferenceExpressionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureReferenceExpressionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class FeatureReferenceExpressionReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public FeatureReferenceExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FeatureReferenceExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureReferenceExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -275,6 +280,10 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -291,6 +300,10 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -341,7 +354,14 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -365,7 +385,14 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -377,7 +404,14 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -389,7 +423,14 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -401,7 +442,14 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -413,7 +461,14 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -425,7 +480,14 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -437,7 +499,14 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -449,7 +518,14 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -461,7 +537,14 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -473,7 +556,14 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -485,7 +575,14 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -499,12 +596,18 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -520,12 +623,18 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -533,6 +642,10 @@ public override IFeatureReferenceExpression Read(XmlReader xmiReader, Uri curren break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureReferenceExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -582,6 +695,8 @@ public override async Task ReadAsync(XmlReader xmiR this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureReferenceExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -610,7 +725,7 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -745,6 +860,10 @@ public override async Task ReadAsync(XmlReader xmiR { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -761,6 +880,10 @@ public override async Task ReadAsync(XmlReader xmiR { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -811,7 +934,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -835,7 +965,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -847,7 +984,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -859,7 +1003,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -871,7 +1022,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -883,7 +1041,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -895,7 +1060,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -907,7 +1079,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -919,7 +1098,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -931,7 +1117,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -943,7 +1136,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -955,7 +1155,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -969,12 +1176,18 @@ public override async Task ReadAsync(XmlReader xmiR { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -990,12 +1203,18 @@ public override async Task ReadAsync(XmlReader xmiR { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1003,6 +1222,10 @@ public override async Task ReadAsync(XmlReader xmiR break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureReferenceExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureTypingReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureTypingReader.cs index c0ef37ab4..bd8457d6a 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureTypingReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureTypingReader.cs @@ -33,11 +33,13 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -62,7 +64,8 @@ public class FeatureTypingReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public FeatureTypingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FeatureTypingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +111,8 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureTyping", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -171,6 +176,10 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -191,6 +200,10 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -207,6 +220,10 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -217,6 +234,10 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var typeXmlAttribute = xmiReader.GetAttribute("type"); @@ -227,6 +248,10 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "type", typeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'type' on element {ElementId}", typeXmlAttribute, poco.Id); + } } var typedFeatureXmlAttribute = xmiReader.GetAttribute("typedFeature"); @@ -237,6 +262,10 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'typedFeature' on element {ElementId}", typedFeatureXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -299,7 +328,14 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -311,7 +347,14 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -325,12 +368,18 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -346,12 +395,18 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -367,12 +422,18 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -388,12 +449,18 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -409,12 +476,18 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var typeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "type", typeId); + if (Guid.TryParse(hrefSplit[1], out var typeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "type", typeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'type' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var typeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var typeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Type = typeValue; } @@ -430,12 +503,18 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var typedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var typedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'typedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var typedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var typedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.TypedFeature = typedFeatureValue; } @@ -443,6 +522,10 @@ public override IFeatureTyping Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureTyping at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -492,6 +575,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureTyping", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -555,6 +640,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -575,6 +664,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -591,6 +684,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -601,6 +698,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var typeXmlAttribute = xmiReader.GetAttribute("type"); @@ -611,6 +712,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "type", typeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'type' on element {ElementId}", typeXmlAttribute, poco.Id); + } } var typedFeatureXmlAttribute = xmiReader.GetAttribute("typedFeature"); @@ -621,6 +726,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'typedFeature' on element {ElementId}", typedFeatureXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -683,7 +792,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -695,7 +811,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -709,12 +832,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -730,12 +859,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -751,12 +886,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -772,12 +913,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -793,12 +940,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var typeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "type", typeId); + if (Guid.TryParse(hrefSplit[1], out var typeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "type", typeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'type' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var typeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var typeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Type = typeValue; } @@ -814,12 +967,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var typedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var typedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "typedFeature", typedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'typedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var typedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var typedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.TypedFeature = typedFeatureValue; } @@ -827,6 +986,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureTyping at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureValueReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureValueReader.cs index 42662135e..5e270b278 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureValueReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FeatureValueReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Kernel.Functions; @@ -40,6 +41,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.FeatureValues; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -64,7 +66,8 @@ public class FeatureValueReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public FeatureValueReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FeatureValueReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -110,6 +113,8 @@ public override IFeatureValue Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureValue", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -193,6 +198,10 @@ public override IFeatureValue Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -213,6 +222,10 @@ public override IFeatureValue Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -229,6 +242,10 @@ public override IFeatureValue Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -239,13 +256,17 @@ public override IFeatureValue Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -311,7 +332,14 @@ public override IFeatureValue Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDefaultValue)) { - poco.IsDefault = bool.Parse(isDefaultValue); + if (bool.TryParse(isDefaultValue, out var isDefaultValueAsBool)) + { + poco.IsDefault = isDefaultValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDefault' on element {ElementId}", isDefaultValue, poco.Id); + } } break; @@ -323,7 +351,14 @@ public override IFeatureValue Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -335,7 +370,14 @@ public override IFeatureValue Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -347,7 +389,14 @@ public override IFeatureValue Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isInitialValue)) { - poco.IsInitial = bool.Parse(isInitialValue); + if (bool.TryParse(isInitialValue, out var isInitialValueAsBool)) + { + poco.IsInitial = isInitialValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isInitial' on element {ElementId}", isInitialValue, poco.Id); + } } break; @@ -361,12 +410,18 @@ public override IFeatureValue Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -382,12 +437,18 @@ public override IFeatureValue Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -403,12 +464,18 @@ public override IFeatureValue Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -424,12 +491,18 @@ public override IFeatureValue Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -443,12 +516,23 @@ public override IFeatureValue Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureValue at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -498,6 +582,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FeatureValue", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -581,6 +667,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -601,6 +691,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -617,6 +711,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -627,13 +725,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -699,7 +801,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isDefaultValue)) { - poco.IsDefault = bool.Parse(isDefaultValue); + if (bool.TryParse(isDefaultValue, out var isDefaultValueAsBool)) + { + poco.IsDefault = isDefaultValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDefault' on element {ElementId}", isDefaultValue, poco.Id); + } } break; @@ -711,7 +820,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -723,7 +839,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -735,7 +858,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isInitialValue)) { - poco.IsInitial = bool.Parse(isInitialValue); + if (bool.TryParse(isInitialValue, out var isInitialValueAsBool)) + { + poco.IsInitial = isInitialValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isInitial' on element {ElementId}", isInitialValue, poco.Id); + } } break; @@ -749,12 +879,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -770,12 +906,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -791,12 +933,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -812,12 +960,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -831,12 +985,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FeatureValue at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowDefinitionReader.cs index 40a98ffd2..222560992 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -64,6 +65,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -88,7 +90,8 @@ public class FlowDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public FlowDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FlowDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -134,6 +137,8 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FlowDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -237,6 +242,10 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -257,6 +266,10 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -273,6 +286,10 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -283,6 +300,10 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -345,7 +366,14 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -357,7 +385,14 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -369,7 +404,14 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -381,7 +423,14 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -393,7 +442,14 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -405,7 +461,14 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -419,12 +482,18 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -440,12 +509,18 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -461,12 +536,18 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -482,12 +563,18 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -495,6 +582,10 @@ public override IFlowDefinition Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FlowDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -544,6 +635,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FlowDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -647,6 +740,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -667,6 +764,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -683,6 +784,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -693,6 +798,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -755,7 +864,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -767,7 +883,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -779,7 +902,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -791,7 +921,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -803,7 +940,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -815,7 +959,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -829,12 +980,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -850,12 +1007,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -871,12 +1034,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -892,12 +1061,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -905,6 +1080,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FlowDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowEndReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowEndReader.cs index 43b446e32..84c2bd036 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowEndReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowEndReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -40,6 +41,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Interactions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -64,7 +66,8 @@ public class FlowEndReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public FlowEndReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FlowEndReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -110,6 +113,8 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FlowEnd", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -138,7 +143,7 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -273,6 +278,10 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -289,6 +298,10 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -339,7 +352,14 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -363,7 +383,14 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -375,7 +402,14 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -387,7 +421,14 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -399,7 +440,14 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -411,7 +459,14 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -423,7 +478,14 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -435,7 +497,14 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -447,7 +516,14 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -459,7 +535,14 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -471,7 +554,14 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -483,7 +573,14 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -497,12 +594,18 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -518,12 +621,18 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -531,6 +640,10 @@ public override IFlowEnd Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FlowEnd at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -580,6 +693,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FlowEnd", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -608,7 +723,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -743,6 +858,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -759,6 +878,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -809,7 +932,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -833,7 +963,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -845,7 +982,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -857,7 +1001,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -869,7 +1020,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -881,7 +1039,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -893,7 +1058,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -905,7 +1077,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -917,7 +1096,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -929,7 +1115,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -941,7 +1134,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -953,7 +1153,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -967,12 +1174,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -988,12 +1201,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1001,6 +1220,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FlowEnd at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowReader.cs index 58d1dfaa5..3ce2915c5 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; @@ -44,6 +45,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Interactions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -68,7 +70,8 @@ public class FlowReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public FlowReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FlowReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -114,6 +117,8 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Flow", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -142,7 +147,7 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -287,6 +292,10 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -307,6 +316,10 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -323,6 +336,10 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -333,6 +350,10 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -383,7 +404,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -407,7 +435,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -419,7 +454,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -431,7 +473,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -443,7 +492,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -455,7 +511,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -467,7 +530,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -479,7 +549,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -491,7 +568,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -503,7 +587,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -515,7 +606,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -527,7 +625,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -539,7 +644,14 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -553,12 +665,18 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -574,12 +692,18 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -595,12 +719,18 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -616,12 +746,18 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -629,6 +765,10 @@ public override IFlow Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Flow at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -678,6 +818,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Flow", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -706,7 +848,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -851,6 +993,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -871,6 +1017,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -887,6 +1037,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -897,6 +1051,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -971,7 +1136,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -983,7 +1155,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -995,7 +1174,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -1007,7 +1193,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1019,7 +1212,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1031,7 +1231,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -1043,7 +1250,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1055,7 +1269,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1067,7 +1288,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1079,7 +1307,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1091,7 +1326,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1103,7 +1345,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1117,12 +1366,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -1138,12 +1393,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1159,12 +1420,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -1180,12 +1447,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1193,6 +1466,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Flow at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowUsageReader.cs index c4e4b70a1..ba517add3 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FlowUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -68,6 +69,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -92,7 +94,8 @@ public class FlowUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public FlowUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FlowUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -138,6 +141,8 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FlowUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -166,7 +171,7 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -321,6 +326,10 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -341,6 +350,10 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -357,6 +370,10 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -367,13 +384,17 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -427,7 +448,14 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -451,7 +479,14 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -463,7 +498,14 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -475,7 +517,14 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -487,7 +536,14 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -499,7 +555,14 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -511,7 +574,14 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -523,7 +593,14 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -535,7 +612,14 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -547,7 +631,14 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -559,7 +650,14 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -571,7 +669,14 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -583,7 +688,14 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -595,7 +707,14 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -609,12 +728,18 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -630,12 +755,18 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -651,12 +782,18 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -672,12 +809,18 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -691,12 +834,23 @@ public override IFlowUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FlowUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -746,6 +900,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FlowUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -774,7 +930,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -929,6 +1085,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -949,6 +1109,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -965,6 +1129,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -975,13 +1143,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -1035,7 +1207,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -1059,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -1071,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -1083,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -1095,7 +1295,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1107,7 +1314,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1119,7 +1333,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -1131,7 +1352,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1143,7 +1371,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1155,7 +1390,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1167,7 +1409,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1179,7 +1428,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1191,7 +1447,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1203,7 +1466,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1217,12 +1487,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -1238,12 +1514,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1259,12 +1541,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -1280,12 +1568,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1299,12 +1593,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FlowUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ForLoopActionUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ForLoopActionUsageReader.cs index 0d30f3117..70a32117b 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ForLoopActionUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ForLoopActionUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class ForLoopActionUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ForLoopActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ForLoopActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ForLoopActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override IForLoopActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ForLoopActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, U this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ForLoopActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader, U { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader, U { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader, U { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader, U { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ForLoopActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ForkNodeReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ForkNodeReader.cs index 8b74189cc..7a7ed8f78 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ForkNodeReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ForkNodeReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -65,6 +66,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -89,7 +91,8 @@ public class ForkNodeReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ForkNodeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ForkNodeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -135,6 +138,8 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ForkNode", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -163,7 +168,7 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -308,6 +313,10 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -324,13 +333,17 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -384,7 +397,14 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -408,7 +428,14 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -420,7 +447,14 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -432,7 +466,14 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -444,7 +485,14 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -456,7 +504,14 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -468,7 +523,14 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -480,7 +542,14 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -492,7 +561,14 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -504,7 +580,14 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -516,7 +599,14 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -528,7 +618,14 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -540,7 +637,14 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -554,12 +658,18 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -575,12 +685,18 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -594,12 +710,23 @@ public override IForkNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ForkNode at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -649,6 +776,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ForkNode", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -677,7 +806,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -822,6 +951,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -838,13 +971,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -898,7 +1035,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -922,7 +1066,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -934,7 +1085,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -946,7 +1104,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -958,7 +1123,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -970,7 +1142,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -982,7 +1161,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -994,7 +1180,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1006,7 +1199,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1018,7 +1218,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1030,7 +1237,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1042,7 +1256,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1054,7 +1275,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1068,12 +1296,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1089,12 +1323,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1108,12 +1348,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ForkNode at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FramedConcernMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FramedConcernMembershipReader.cs index 1241d8d31..56e3ac930 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FramedConcernMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FramedConcernMembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.Systems.Requirements; using SysML2.NET.Core.POCO.Core.Features; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.Constraints; using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class FramedConcernMembershipReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public FramedConcernMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FramedConcernMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FramedConcernMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -167,7 +172,7 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(kindXmlAttribute)) { - if (Enum.TryParse(kindXmlAttribute, true, out RequirementConstraintKind kindXmlAttributeAsEnum)) + if (RequirementConstraintKindProvider.TryParse(kindXmlAttribute.AsSpan(), out var kindXmlAttributeAsEnum)) { poco.Kind = kindXmlAttributeAsEnum; } @@ -185,6 +190,10 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -205,6 +214,10 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -221,6 +234,10 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -231,13 +248,17 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -303,7 +324,14 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -315,7 +343,14 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -327,7 +362,14 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(kindValue)) { - poco.Kind = (RequirementConstraintKind)Enum.Parse(typeof(RequirementConstraintKind), kindValue, true); + if (RequirementConstraintKindProvider.TryParse(kindValue.AsSpan(), out var kindValueAsEnum)) + { + poco.Kind = kindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'kind' on element {ElementId}", kindValue, poco.Id); + } } break; @@ -341,12 +383,18 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -362,12 +410,18 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -383,12 +437,18 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -404,12 +464,18 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -423,12 +489,23 @@ public override IFramedConcernMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FramedConcernMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -478,6 +555,8 @@ public override async Task ReadAsync(XmlReader xmiRead this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "FramedConcernMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -533,7 +612,7 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(kindXmlAttribute)) { - if (Enum.TryParse(kindXmlAttribute, true, out RequirementConstraintKind kindXmlAttributeAsEnum)) + if (RequirementConstraintKindProvider.TryParse(kindXmlAttribute.AsSpan(), out var kindXmlAttributeAsEnum)) { poco.Kind = kindXmlAttributeAsEnum; } @@ -551,6 +630,10 @@ public override async Task ReadAsync(XmlReader xmiRead { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -571,6 +654,10 @@ public override async Task ReadAsync(XmlReader xmiRead { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -587,6 +674,10 @@ public override async Task ReadAsync(XmlReader xmiRead { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -597,13 +688,17 @@ public override async Task ReadAsync(XmlReader xmiRead { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -669,7 +764,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -681,7 +783,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -693,7 +802,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(kindValue)) { - poco.Kind = (RequirementConstraintKind)Enum.Parse(typeof(RequirementConstraintKind), kindValue, true); + if (RequirementConstraintKindProvider.TryParse(kindValue.AsSpan(), out var kindValueAsEnum)) + { + poco.Kind = kindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'kind' on element {ElementId}", kindValue, poco.Id); + } } break; @@ -707,12 +823,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -728,12 +850,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -749,12 +877,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -770,12 +904,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -789,12 +929,23 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading FramedConcernMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FunctionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FunctionReader.cs index 46fbcf7d3..5fd8a1bb3 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FunctionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/FunctionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -41,6 +42,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -65,7 +67,8 @@ public class FunctionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public FunctionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public FunctionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +114,8 @@ public override IFunction Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Function", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -184,6 +189,10 @@ public override IFunction Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -200,6 +209,10 @@ public override IFunction Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -262,7 +275,14 @@ public override IFunction Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -274,7 +294,14 @@ public override IFunction Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -286,7 +313,14 @@ public override IFunction Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -300,12 +334,18 @@ public override IFunction Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -321,12 +361,18 @@ public override IFunction Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -334,6 +380,10 @@ public override IFunction Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Function at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -383,6 +433,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Function", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -456,6 +508,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -472,6 +528,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -534,7 +594,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -546,7 +613,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -558,7 +632,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -572,12 +653,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -593,12 +680,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -606,6 +699,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Function at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IfActionUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IfActionUsageReader.cs index 5a2e6ecf3..e44078083 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IfActionUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IfActionUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class IfActionUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public IfActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public IfActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "IfActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override IIfActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading IfActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "IfActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading IfActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IncludeUseCaseUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IncludeUseCaseUsageReader.cs index 584468bd6..ff480c1f8 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IncludeUseCaseUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IncludeUseCaseUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class IncludeUseCaseUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public IncludeUseCaseUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public IncludeUseCaseUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "IncludeUseCaseUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override IIncludeUseCaseUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading IncludeUseCaseUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "IncludeUseCaseUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading IncludeUseCaseUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IndexExpressionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IndexExpressionReader.cs index b5a68f3bd..6d52e4af7 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IndexExpressionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IndexExpressionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class IndexExpressionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public IndexExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public IndexExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "IndexExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -282,6 +287,10 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -298,6 +307,10 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -348,7 +361,14 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -372,7 +392,14 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -384,7 +411,14 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -396,7 +430,14 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -408,7 +449,14 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -420,7 +468,14 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -432,7 +487,14 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -444,7 +506,14 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -456,7 +525,14 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -468,7 +544,14 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -480,7 +563,14 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -492,7 +582,14 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -518,12 +615,18 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -539,12 +642,18 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -552,6 +661,10 @@ public override IIndexExpression Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading IndexExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -601,6 +714,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "IndexExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -629,7 +744,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -771,6 +886,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -787,6 +906,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -837,7 +960,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -861,7 +991,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -873,7 +1010,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -885,7 +1029,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -897,7 +1048,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -909,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -921,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -933,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -945,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -957,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -969,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -981,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1007,12 +1214,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1028,12 +1241,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1041,6 +1260,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading IndexExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InteractionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InteractionReader.cs index 7e3040d98..8dad385f3 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InteractionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InteractionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Interactions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class InteractionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public InteractionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public InteractionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override IInteraction Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Interaction", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -195,6 +200,10 @@ public override IInteraction Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -215,6 +224,10 @@ public override IInteraction Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -231,6 +244,10 @@ public override IInteraction Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -241,6 +258,10 @@ public override IInteraction Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -303,7 +324,14 @@ public override IInteraction Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -315,7 +343,14 @@ public override IInteraction Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -327,7 +362,14 @@ public override IInteraction Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -339,7 +381,14 @@ public override IInteraction Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -353,12 +402,18 @@ public override IInteraction Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -374,12 +429,18 @@ public override IInteraction Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -395,12 +456,18 @@ public override IInteraction Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -416,12 +483,18 @@ public override IInteraction Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -429,6 +502,10 @@ public override IInteraction Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Interaction at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -478,6 +555,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Interaction", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -561,6 +640,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -581,6 +664,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -597,6 +684,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -607,6 +698,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -669,7 +764,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -681,7 +783,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -693,7 +802,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -705,7 +821,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -719,12 +842,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -740,12 +869,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -761,12 +896,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -782,12 +923,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -795,6 +942,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curr break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Interaction at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InterfaceDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InterfaceDefinitionReader.cs index 05f047fcf..5ce2b7e32 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InterfaceDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InterfaceDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -62,6 +63,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -86,7 +88,8 @@ public class InterfaceDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public InterfaceDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public InterfaceDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -132,6 +135,8 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "InterfaceDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -235,6 +240,10 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -255,6 +264,10 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -271,6 +284,10 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -281,6 +298,10 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -343,7 +364,14 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -355,7 +383,14 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -367,7 +402,14 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -379,7 +421,14 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -391,7 +440,14 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -403,7 +459,14 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -417,12 +480,18 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -438,12 +507,18 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -459,12 +534,18 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -480,12 +561,18 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -493,6 +580,10 @@ public override IInterfaceDefinition Read(XmlReader xmiReader, Uri currentLocati break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading InterfaceDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -542,6 +633,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "InterfaceDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -645,6 +738,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -665,6 +762,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -681,6 +782,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -691,6 +796,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -753,7 +862,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -765,7 +881,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -777,7 +900,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -789,7 +919,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -801,7 +938,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -813,7 +957,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -827,12 +978,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -848,12 +1005,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -869,12 +1032,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -890,12 +1059,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -903,6 +1078,10 @@ public override async Task ReadAsync(XmlReader xmiReader, break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading InterfaceDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InterfaceUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InterfaceUsageReader.cs index f01d8e912..0a856aade 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InterfaceUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InterfaceUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -67,6 +68,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -91,7 +93,8 @@ public class InterfaceUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public InterfaceUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public InterfaceUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -137,6 +140,8 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "InterfaceUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -165,7 +170,7 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -320,6 +325,10 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -340,6 +349,10 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -356,6 +369,10 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -366,13 +383,17 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -426,7 +447,14 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -450,7 +478,14 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -462,7 +497,14 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -474,7 +516,14 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -486,7 +535,14 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -498,7 +554,14 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -510,7 +573,14 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -522,7 +592,14 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -534,7 +611,14 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -546,7 +630,14 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -558,7 +649,14 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -570,7 +668,14 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -582,7 +687,14 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -594,7 +706,14 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -608,12 +727,18 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -629,12 +754,18 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -650,12 +781,18 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -671,12 +808,18 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -690,12 +833,23 @@ public override IInterfaceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading InterfaceUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -745,6 +899,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "InterfaceUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -773,7 +929,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -928,6 +1084,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -948,6 +1108,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -964,6 +1128,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -974,13 +1142,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -1034,7 +1206,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -1058,7 +1237,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -1070,7 +1256,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -1082,7 +1275,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -1094,7 +1294,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1106,7 +1313,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1118,7 +1332,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -1130,7 +1351,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1142,7 +1370,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1154,7 +1389,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1166,7 +1408,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1178,7 +1427,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1190,7 +1446,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1202,7 +1465,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1216,12 +1486,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -1237,12 +1513,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1258,12 +1540,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -1279,12 +1567,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1298,12 +1592,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading InterfaceUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IntersectingReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IntersectingReader.cs index 553fed90d..017d47e2b 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IntersectingReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/IntersectingReader.cs @@ -33,10 +33,12 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -61,7 +63,8 @@ public class IntersectingReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public IntersectingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public IntersectingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -107,6 +110,8 @@ public override IIntersecting Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Intersecting", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -146,6 +151,10 @@ public override IIntersecting Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "intersectingType", intersectingTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'intersectingType' on element {ElementId}", intersectingTypeXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -180,6 +189,10 @@ public override IIntersecting Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -200,6 +213,10 @@ public override IIntersecting Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -216,6 +233,10 @@ public override IIntersecting Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -226,6 +247,10 @@ public override IIntersecting Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -290,12 +315,18 @@ public override IIntersecting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var intersectingTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "intersectingType", intersectingTypeId); + if (Guid.TryParse(hrefSplit[1], out var intersectingTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "intersectingType", intersectingTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'intersectingType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var intersectingTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var intersectingTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.IntersectingType = intersectingTypeValue; } @@ -309,7 +340,14 @@ public override IIntersecting Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -321,7 +359,14 @@ public override IIntersecting Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -335,12 +380,18 @@ public override IIntersecting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -356,12 +407,18 @@ public override IIntersecting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -377,12 +434,18 @@ public override IIntersecting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -398,12 +461,18 @@ public override IIntersecting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -411,6 +480,10 @@ public override IIntersecting Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Intersecting at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -460,6 +533,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Intersecting", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -499,6 +574,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "intersectingType", intersectingTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'intersectingType' on element {ElementId}", intersectingTypeXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -533,6 +612,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -553,6 +636,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -569,6 +656,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -579,6 +670,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -643,12 +738,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var intersectingTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "intersectingType", intersectingTypeId); + if (Guid.TryParse(hrefSplit[1], out var intersectingTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "intersectingType", intersectingTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'intersectingType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var intersectingTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var intersectingTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.IntersectingType = intersectingTypeValue; } @@ -662,7 +763,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -674,7 +782,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -688,12 +803,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -709,12 +830,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -730,12 +857,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -751,12 +884,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -764,6 +903,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Intersecting at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InvariantReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InvariantReader.cs index 8419fff0e..58fb40b42 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InvariantReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InvariantReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -41,6 +42,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -65,7 +67,8 @@ public class InvariantReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public InvariantReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public InvariantReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +114,8 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Invariant", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -139,7 +144,7 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -284,6 +289,10 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -300,6 +309,10 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -350,7 +363,14 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -374,7 +394,14 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -386,7 +413,14 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -398,7 +432,14 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -410,7 +451,14 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -422,7 +470,14 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -434,7 +489,14 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -446,7 +508,14 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isNegatedValue)) { - poco.IsNegated = bool.Parse(isNegatedValue); + if (bool.TryParse(isNegatedValue, out var isNegatedValueAsBool)) + { + poco.IsNegated = isNegatedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isNegated' on element {ElementId}", isNegatedValue, poco.Id); + } } break; @@ -458,7 +527,14 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -470,7 +546,14 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -482,7 +565,14 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -494,7 +584,14 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -506,7 +603,14 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -520,12 +624,18 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -541,12 +651,18 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -554,6 +670,10 @@ public override IInvariant Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Invariant at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -603,6 +723,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Invariant", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -631,7 +753,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -776,6 +898,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -792,6 +918,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -842,7 +972,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -866,7 +1003,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -878,7 +1022,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -890,7 +1041,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -902,7 +1060,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -914,7 +1079,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -926,7 +1098,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -938,7 +1117,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isNegatedValue)) { - poco.IsNegated = bool.Parse(isNegatedValue); + if (bool.TryParse(isNegatedValue, out var isNegatedValueAsBool)) + { + poco.IsNegated = isNegatedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isNegated' on element {ElementId}", isNegatedValue, poco.Id); + } } break; @@ -950,7 +1136,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -962,7 +1155,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -974,7 +1174,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -986,7 +1193,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -998,7 +1212,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1012,12 +1233,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1033,12 +1260,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1046,6 +1279,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Invariant at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InvocationExpressionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InvocationExpressionReader.cs index c75147ba5..df1c1c992 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InvocationExpressionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/InvocationExpressionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class InvocationExpressionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public InvocationExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public InvocationExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "InvocationExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -275,6 +280,10 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -291,6 +300,10 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -341,7 +354,14 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -365,7 +385,14 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -377,7 +404,14 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -389,7 +423,14 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -401,7 +442,14 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -413,7 +461,14 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -425,7 +480,14 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -437,7 +499,14 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -449,7 +518,14 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -461,7 +537,14 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -473,7 +556,14 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -485,7 +575,14 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -499,12 +596,18 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -520,12 +623,18 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -533,6 +642,10 @@ public override IInvocationExpression Read(XmlReader xmiReader, Uri currentLocat break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading InvocationExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -582,6 +695,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "InvocationExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -610,7 +725,7 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -745,6 +860,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -761,6 +880,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -811,7 +934,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -835,7 +965,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -847,7 +984,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -859,7 +1003,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -871,7 +1022,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -883,7 +1041,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -895,7 +1060,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -907,7 +1079,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -919,7 +1098,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -931,7 +1117,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -943,7 +1136,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -955,7 +1155,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -969,12 +1176,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -990,12 +1203,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1003,6 +1222,10 @@ public override async Task ReadAsync(XmlReader xmiReader, break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading InvocationExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ItemDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ItemDefinitionReader.cs index 371551f65..5ffe86e99 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ItemDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ItemDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -62,6 +63,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -86,7 +88,8 @@ public class ItemDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ItemDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ItemDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -132,6 +135,8 @@ public override IItemDefinition Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ItemDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -225,6 +230,10 @@ public override IItemDefinition Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -241,6 +250,10 @@ public override IItemDefinition Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -303,7 +316,14 @@ public override IItemDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -315,7 +335,14 @@ public override IItemDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -327,7 +354,14 @@ public override IItemDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -339,7 +373,14 @@ public override IItemDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -351,7 +392,14 @@ public override IItemDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -365,12 +413,18 @@ public override IItemDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -386,12 +440,18 @@ public override IItemDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -399,6 +459,10 @@ public override IItemDefinition Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ItemDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -448,6 +512,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ItemDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -541,6 +607,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -557,6 +627,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -619,7 +693,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -631,7 +712,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -643,7 +731,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -655,7 +750,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -667,7 +769,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -681,12 +790,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -702,12 +817,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -715,6 +836,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ItemDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ItemUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ItemUsageReader.cs index a80dfd58b..c7f81216e 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ItemUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ItemUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -65,6 +66,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -89,7 +91,8 @@ public class ItemUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ItemUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ItemUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -135,6 +138,8 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ItemUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -163,7 +168,7 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -308,6 +313,10 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -324,13 +333,17 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -384,7 +397,14 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -408,7 +428,14 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -420,7 +447,14 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -432,7 +466,14 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -444,7 +485,14 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -456,7 +504,14 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -468,7 +523,14 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -480,7 +542,14 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -492,7 +561,14 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -504,7 +580,14 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -516,7 +599,14 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -528,7 +618,14 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -540,7 +637,14 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -554,12 +658,18 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -575,12 +685,18 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -594,12 +710,23 @@ public override IItemUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ItemUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -649,6 +776,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ItemUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -677,7 +806,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -822,6 +951,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -838,13 +971,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -898,7 +1035,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -922,7 +1066,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -934,7 +1085,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -946,7 +1104,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -958,7 +1123,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -970,7 +1142,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -982,7 +1161,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -994,7 +1180,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1006,7 +1199,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1018,7 +1218,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1030,7 +1237,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1042,7 +1256,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1054,7 +1275,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1068,12 +1296,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1089,12 +1323,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1108,12 +1348,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ItemUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/JoinNodeReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/JoinNodeReader.cs index 7dfcafad7..261324ee4 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/JoinNodeReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/JoinNodeReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -65,6 +66,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -89,7 +91,8 @@ public class JoinNodeReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public JoinNodeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public JoinNodeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -135,6 +138,8 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "JoinNode", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -163,7 +168,7 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -308,6 +313,10 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -324,13 +333,17 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -384,7 +397,14 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -408,7 +428,14 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -420,7 +447,14 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -432,7 +466,14 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -444,7 +485,14 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -456,7 +504,14 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -468,7 +523,14 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -480,7 +542,14 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -492,7 +561,14 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -504,7 +580,14 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -516,7 +599,14 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -528,7 +618,14 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -540,7 +637,14 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -554,12 +658,18 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -575,12 +685,18 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -594,12 +710,23 @@ public override IJoinNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading JoinNode at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -649,6 +776,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "JoinNode", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -677,7 +806,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -822,6 +951,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -838,13 +971,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -898,7 +1035,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -922,7 +1066,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -934,7 +1085,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -946,7 +1104,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -958,7 +1123,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -970,7 +1142,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -982,7 +1161,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -994,7 +1180,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1006,7 +1199,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1018,7 +1218,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1030,7 +1237,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1042,7 +1256,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1054,7 +1275,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1068,12 +1296,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1089,12 +1323,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1108,12 +1348,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading JoinNode at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LibraryPackageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LibraryPackageReader.cs index e5412779c..b0fbaba9c 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LibraryPackageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LibraryPackageReader.cs @@ -33,11 +33,13 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Kernel.Functions; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Packages; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -62,7 +64,8 @@ public class LibraryPackageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public LibraryPackageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public LibraryPackageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +111,8 @@ public override ILibraryPackage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LibraryPackage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -171,6 +176,10 @@ public override ILibraryPackage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -187,6 +196,10 @@ public override ILibraryPackage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -249,7 +262,14 @@ public override ILibraryPackage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -261,7 +281,14 @@ public override ILibraryPackage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isStandardValue)) { - poco.IsStandard = bool.Parse(isStandardValue); + if (bool.TryParse(isStandardValue, out var isStandardValueAsBool)) + { + poco.IsStandard = isStandardValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isStandard' on element {ElementId}", isStandardValue, poco.Id); + } } break; @@ -275,12 +302,18 @@ public override ILibraryPackage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -296,12 +329,18 @@ public override ILibraryPackage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -309,6 +348,10 @@ public override ILibraryPackage Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LibraryPackage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -358,6 +401,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LibraryPackage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -421,6 +466,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -437,6 +486,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -499,7 +552,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -511,7 +571,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isStandardValue)) { - poco.IsStandard = bool.Parse(isStandardValue); + if (bool.TryParse(isStandardValue, out var isStandardValueAsBool)) + { + poco.IsStandard = isStandardValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isStandard' on element {ElementId}", isStandardValue, poco.Id); + } } break; @@ -525,12 +592,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -546,12 +619,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -559,6 +638,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LibraryPackage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralBooleanReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralBooleanReader.cs index a7a13c142..07f8ac087 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralBooleanReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralBooleanReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class LiteralBooleanReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public LiteralBooleanReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public LiteralBooleanReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralBoolean", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -275,6 +280,10 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -291,6 +300,10 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var valueXmlAttribute = xmiReader.GetAttribute("value"); @@ -351,7 +364,14 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -375,7 +395,14 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -387,7 +414,14 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -399,7 +433,14 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -411,7 +452,14 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -423,7 +471,14 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -435,7 +490,14 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -447,7 +509,14 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -459,7 +528,14 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -471,7 +547,14 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -483,7 +566,14 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -495,7 +585,14 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -509,12 +606,18 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -530,12 +633,18 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -549,12 +658,23 @@ public override ILiteralBoolean Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(valueValue)) { - poco.Value = bool.Parse(valueValue); + if (bool.TryParse(valueValue, out var valueValueAsBool)) + { + poco.Value = valueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'value' on element {ElementId}", valueValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralBoolean at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -604,6 +724,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralBoolean", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -632,7 +754,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -767,6 +889,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -783,6 +909,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var valueXmlAttribute = xmiReader.GetAttribute("value"); @@ -843,7 +973,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -867,7 +1004,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -879,7 +1023,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -891,7 +1042,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -903,7 +1061,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -915,7 +1080,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -927,7 +1099,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -939,7 +1118,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -951,7 +1137,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -963,7 +1156,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -975,7 +1175,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -987,7 +1194,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1001,12 +1215,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1022,12 +1242,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1041,12 +1267,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(valueValue)) { - poco.Value = bool.Parse(valueValue); + if (bool.TryParse(valueValue, out var valueValueAsBool)) + { + poco.Value = valueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'value' on element {ElementId}", valueValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralBoolean at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralExpressionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralExpressionReader.cs index 5c9a513ce..83e3821ab 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralExpressionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralExpressionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class LiteralExpressionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public LiteralExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public LiteralExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -275,6 +280,10 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -291,6 +300,10 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -341,7 +354,14 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -365,7 +385,14 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -377,7 +404,14 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -389,7 +423,14 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -401,7 +442,14 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -413,7 +461,14 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -425,7 +480,14 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -437,7 +499,14 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -449,7 +518,14 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -461,7 +537,14 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -473,7 +556,14 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -485,7 +575,14 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -499,12 +596,18 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -520,12 +623,18 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -533,6 +642,10 @@ public override ILiteralExpression Read(XmlReader xmiReader, Uri currentLocation break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -582,6 +695,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -610,7 +725,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -745,6 +860,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -761,6 +880,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -811,7 +934,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -835,7 +965,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -847,7 +984,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -859,7 +1003,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -871,7 +1022,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -883,7 +1041,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -895,7 +1060,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -907,7 +1079,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -919,7 +1098,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -931,7 +1117,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -943,7 +1136,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -955,7 +1155,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -969,12 +1176,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -990,12 +1203,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1003,6 +1222,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralInfinityReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralInfinityReader.cs index b7064d4c4..a580ab317 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralInfinityReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralInfinityReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class LiteralInfinityReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public LiteralInfinityReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public LiteralInfinityReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralInfinity", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -275,6 +280,10 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -291,6 +300,10 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -341,7 +354,14 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -365,7 +385,14 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -377,7 +404,14 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -389,7 +423,14 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -401,7 +442,14 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -413,7 +461,14 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -425,7 +480,14 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -437,7 +499,14 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -449,7 +518,14 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -461,7 +537,14 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -473,7 +556,14 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -485,7 +575,14 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -499,12 +596,18 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -520,12 +623,18 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -533,6 +642,10 @@ public override ILiteralInfinity Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralInfinity at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -582,6 +695,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralInfinity", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -610,7 +725,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -745,6 +860,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -761,6 +880,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -811,7 +934,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -835,7 +965,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -847,7 +984,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -859,7 +1003,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -871,7 +1022,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -883,7 +1041,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -895,7 +1060,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -907,7 +1079,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -919,7 +1098,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -931,7 +1117,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -943,7 +1136,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -955,7 +1155,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -969,12 +1176,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -990,12 +1203,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1003,6 +1222,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralInfinity at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralIntegerReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralIntegerReader.cs index dfaf84eb0..e97980cde 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralIntegerReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralIntegerReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class LiteralIntegerReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public LiteralIntegerReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public LiteralIntegerReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralInteger", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -275,6 +280,10 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -291,6 +300,10 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var valueXmlAttribute = xmiReader.GetAttribute("value"); @@ -351,7 +364,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -375,7 +395,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -387,7 +414,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -399,7 +433,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -411,7 +452,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -423,7 +471,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -435,7 +490,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -447,7 +509,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -459,7 +528,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -471,7 +547,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -483,7 +566,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -495,7 +585,14 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -509,12 +606,18 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -530,12 +633,18 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -549,12 +658,23 @@ public override ILiteralInteger Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(valueValue)) { - poco.Value = int.Parse(valueValue); + if (int.TryParse(valueValue, out var valueValueAsInt)) + { + poco.Value = valueValueAsInt; + } + else + { + this.logger.LogWarning("Failed to parse int value '{Value}' for property 'value' on element {ElementId}", valueValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralInteger at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -604,6 +724,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralInteger", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -632,7 +754,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -767,6 +889,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -783,6 +909,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var valueXmlAttribute = xmiReader.GetAttribute("value"); @@ -843,7 +973,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -867,7 +1004,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -879,7 +1023,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -891,7 +1042,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -903,7 +1061,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -915,7 +1080,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -927,7 +1099,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -939,7 +1118,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -951,7 +1137,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -963,7 +1156,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -975,7 +1175,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -987,7 +1194,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1001,12 +1215,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1022,12 +1242,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1041,12 +1267,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(valueValue)) { - poco.Value = int.Parse(valueValue); + if (int.TryParse(valueValue, out var valueValueAsInt)) + { + poco.Value = valueValueAsInt; + } + else + { + this.logger.LogWarning("Failed to parse int value '{Value}' for property 'value' on element {ElementId}", valueValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralInteger at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralRationalReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralRationalReader.cs index 23c2276b3..b08510e1f 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralRationalReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralRationalReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class LiteralRationalReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public LiteralRationalReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public LiteralRationalReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralRational", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -275,6 +280,10 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -291,6 +300,10 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var valueXmlAttribute = xmiReader.GetAttribute("value"); @@ -351,7 +364,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -375,7 +395,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -387,7 +414,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -399,7 +433,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -411,7 +452,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -423,7 +471,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -435,7 +490,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -447,7 +509,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -459,7 +528,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -471,7 +547,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -483,7 +566,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -495,7 +585,14 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -509,12 +606,18 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -530,12 +633,18 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -549,12 +658,23 @@ public override ILiteralRational Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(valueValue)) { - poco.Value = double.Parse(valueValue); + if (double.TryParse(valueValue, out var valueValueAsDouble)) + { + poco.Value = valueValueAsDouble; + } + else + { + this.logger.LogWarning("Failed to parse double value '{Value}' for property 'value' on element {ElementId}", valueValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralRational at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -604,6 +724,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralRational", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -632,7 +754,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -767,6 +889,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -783,6 +909,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var valueXmlAttribute = xmiReader.GetAttribute("value"); @@ -843,7 +973,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -867,7 +1004,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -879,7 +1023,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -891,7 +1042,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -903,7 +1061,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -915,7 +1080,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -927,7 +1099,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -939,7 +1118,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -951,7 +1137,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -963,7 +1156,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -975,7 +1175,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -987,7 +1194,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1001,12 +1215,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1022,12 +1242,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1041,12 +1267,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(valueValue)) { - poco.Value = double.Parse(valueValue); + if (double.TryParse(valueValue, out var valueValueAsDouble)) + { + poco.Value = valueValueAsDouble; + } + else + { + this.logger.LogWarning("Failed to parse double value '{Value}' for property 'value' on element {ElementId}", valueValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralRational at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralStringReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralStringReader.cs index 9a5348467..b4264a2d5 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralStringReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/LiteralStringReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class LiteralStringReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public LiteralStringReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public LiteralStringReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralString", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -275,6 +280,10 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -291,6 +300,10 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var valueXmlAttribute = xmiReader.GetAttribute("value"); @@ -348,7 +361,14 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -372,7 +392,14 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -384,7 +411,14 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -396,7 +430,14 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -408,7 +449,14 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -420,7 +468,14 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -432,7 +487,14 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -444,7 +506,14 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -456,7 +525,14 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -468,7 +544,14 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -480,7 +563,14 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -492,7 +582,14 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -506,12 +603,18 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -527,12 +630,18 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -552,6 +661,10 @@ public override ILiteralString Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralString at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -601,6 +714,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "LiteralString", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -629,7 +744,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -764,6 +879,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -780,6 +899,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var valueXmlAttribute = xmiReader.GetAttribute("value"); @@ -837,7 +960,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -861,7 +991,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -873,7 +1010,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -885,7 +1029,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -897,7 +1048,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -909,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -921,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -933,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -945,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -957,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -969,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -981,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -995,12 +1202,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1016,12 +1229,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1041,6 +1260,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading LiteralString at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MembershipExposeReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MembershipExposeReader.cs index 190e51c5b..b4ea09c67 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MembershipExposeReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MembershipExposeReader.cs @@ -33,11 +33,13 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -62,7 +64,8 @@ public class MembershipExposeReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public MembershipExposeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public MembershipExposeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +111,8 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MembershipExpose", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -147,6 +152,10 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedMembership", importedMembershipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'importedMembership' on element {ElementId}", importedMembershipXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -201,6 +210,10 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -221,6 +234,10 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -237,6 +254,10 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -247,13 +268,17 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -321,12 +346,18 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var importedMembershipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedMembership", importedMembershipId); + if (Guid.TryParse(hrefSplit[1], out var importedMembershipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedMembership", importedMembershipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'importedMembership' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var importedMembershipValue = (IMembership)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var importedMembershipValue = (IMembership)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ImportedMembership = importedMembershipValue; } @@ -340,7 +371,14 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -352,7 +390,14 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -364,7 +409,14 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImportAllValue)) { - poco.IsImportAll = bool.Parse(isImportAllValue); + if (bool.TryParse(isImportAllValue, out var isImportAllValueAsBool)) + { + poco.IsImportAll = isImportAllValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImportAll' on element {ElementId}", isImportAllValue, poco.Id); + } } break; @@ -376,7 +428,14 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isRecursiveValue)) { - poco.IsRecursive = bool.Parse(isRecursiveValue); + if (bool.TryParse(isRecursiveValue, out var isRecursiveValueAsBool)) + { + poco.IsRecursive = isRecursiveValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isRecursive' on element {ElementId}", isRecursiveValue, poco.Id); + } } break; @@ -390,12 +449,18 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -411,12 +476,18 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -432,12 +503,18 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -453,12 +530,18 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -472,12 +555,23 @@ public override IMembershipExpose Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MembershipExpose at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -527,6 +621,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MembershipExpose", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -566,6 +662,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedMembership", importedMembershipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'importedMembership' on element {ElementId}", importedMembershipXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -620,6 +720,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -640,6 +744,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -656,6 +764,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -666,13 +778,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -740,12 +856,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var importedMembershipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedMembership", importedMembershipId); + if (Guid.TryParse(hrefSplit[1], out var importedMembershipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedMembership", importedMembershipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'importedMembership' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var importedMembershipValue = (IMembership)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var importedMembershipValue = (IMembership)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ImportedMembership = importedMembershipValue; } @@ -759,7 +881,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -771,7 +900,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -783,7 +919,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImportAllValue)) { - poco.IsImportAll = bool.Parse(isImportAllValue); + if (bool.TryParse(isImportAllValue, out var isImportAllValueAsBool)) + { + poco.IsImportAll = isImportAllValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImportAll' on element {ElementId}", isImportAllValue, poco.Id); + } } break; @@ -795,7 +938,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isRecursiveValue)) { - poco.IsRecursive = bool.Parse(isRecursiveValue); + if (bool.TryParse(isRecursiveValue, out var isRecursiveValueAsBool)) + { + poco.IsRecursive = isRecursiveValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isRecursive' on element {ElementId}", isRecursiveValue, poco.Id); + } } break; @@ -809,12 +959,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -830,12 +986,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -851,12 +1013,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -872,12 +1040,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -891,12 +1065,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MembershipExpose at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MembershipImportReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MembershipImportReader.cs index aa620872c..172277f5e 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MembershipImportReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MembershipImportReader.cs @@ -33,10 +33,12 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -61,7 +63,8 @@ public class MembershipImportReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public MembershipImportReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public MembershipImportReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -107,6 +110,8 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MembershipImport", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -146,6 +151,10 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedMembership", importedMembershipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'importedMembership' on element {ElementId}", importedMembershipXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -200,6 +209,10 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -220,6 +233,10 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -236,6 +253,10 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -246,13 +267,17 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -320,12 +345,18 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var importedMembershipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedMembership", importedMembershipId); + if (Guid.TryParse(hrefSplit[1], out var importedMembershipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedMembership", importedMembershipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'importedMembership' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var importedMembershipValue = (IMembership)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var importedMembershipValue = (IMembership)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ImportedMembership = importedMembershipValue; } @@ -339,7 +370,14 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -351,7 +389,14 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -363,7 +408,14 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImportAllValue)) { - poco.IsImportAll = bool.Parse(isImportAllValue); + if (bool.TryParse(isImportAllValue, out var isImportAllValueAsBool)) + { + poco.IsImportAll = isImportAllValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImportAll' on element {ElementId}", isImportAllValue, poco.Id); + } } break; @@ -375,7 +427,14 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isRecursiveValue)) { - poco.IsRecursive = bool.Parse(isRecursiveValue); + if (bool.TryParse(isRecursiveValue, out var isRecursiveValueAsBool)) + { + poco.IsRecursive = isRecursiveValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isRecursive' on element {ElementId}", isRecursiveValue, poco.Id); + } } break; @@ -389,12 +448,18 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -410,12 +475,18 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -431,12 +502,18 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -452,12 +529,18 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -471,12 +554,23 @@ public override IMembershipImport Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MembershipImport at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -526,6 +620,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MembershipImport", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -565,6 +661,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedMembership", importedMembershipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'importedMembership' on element {ElementId}", importedMembershipXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -619,6 +719,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -639,6 +743,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -655,6 +763,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -665,13 +777,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -739,12 +855,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var importedMembershipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedMembership", importedMembershipId); + if (Guid.TryParse(hrefSplit[1], out var importedMembershipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedMembership", importedMembershipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'importedMembership' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var importedMembershipValue = (IMembership)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var importedMembershipValue = (IMembership)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ImportedMembership = importedMembershipValue; } @@ -758,7 +880,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -770,7 +899,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -782,7 +918,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImportAllValue)) { - poco.IsImportAll = bool.Parse(isImportAllValue); + if (bool.TryParse(isImportAllValue, out var isImportAllValueAsBool)) + { + poco.IsImportAll = isImportAllValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImportAll' on element {ElementId}", isImportAllValue, poco.Id); + } } break; @@ -794,7 +937,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isRecursiveValue)) { - poco.IsRecursive = bool.Parse(isRecursiveValue); + if (bool.TryParse(isRecursiveValue, out var isRecursiveValueAsBool)) + { + poco.IsRecursive = isRecursiveValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isRecursive' on element {ElementId}", isRecursiveValue, poco.Id); + } } break; @@ -808,12 +958,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -829,12 +985,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -850,12 +1012,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -871,12 +1039,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -890,12 +1064,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MembershipImport at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MembershipReader.cs index 7bfacadba..ea4c13313 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MembershipReader.cs @@ -33,10 +33,12 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -61,7 +63,8 @@ public class MembershipReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public MembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public MembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -107,6 +110,8 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Membership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -166,6 +171,10 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "memberElement", memberElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'memberElement' on element {ElementId}", memberElementXmlAttribute, poco.Id); + } } var memberNameXmlAttribute = xmiReader.GetAttribute("memberName"); @@ -194,6 +203,10 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -214,6 +227,10 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -230,6 +247,10 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -240,13 +261,17 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -312,7 +337,14 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -324,7 +356,14 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -338,12 +377,18 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var memberElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "memberElement", memberElementId); + if (Guid.TryParse(hrefSplit[1], out var memberElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "memberElement", memberElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'memberElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var memberElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var memberElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.MemberElement = memberElementValue; } @@ -383,12 +428,18 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -404,12 +455,18 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -425,12 +482,18 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -446,12 +509,18 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -465,12 +534,23 @@ public override IMembership Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Membership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -520,6 +600,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Membership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -579,6 +661,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "memberElement", memberElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'memberElement' on element {ElementId}", memberElementXmlAttribute, poco.Id); + } } var memberNameXmlAttribute = xmiReader.GetAttribute("memberName"); @@ -607,6 +693,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -627,6 +717,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -643,6 +737,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -653,13 +751,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -725,7 +827,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -737,7 +846,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -751,12 +867,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var memberElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "memberElement", memberElementId); + if (Guid.TryParse(hrefSplit[1], out var memberElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "memberElement", memberElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'memberElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var memberElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var memberElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.MemberElement = memberElementValue; } @@ -796,12 +918,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -817,12 +945,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -838,12 +972,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -859,12 +999,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -878,12 +1024,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Membership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MergeNodeReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MergeNodeReader.cs index a6861a7e5..d1d3a8faf 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MergeNodeReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MergeNodeReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -65,6 +66,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -89,7 +91,8 @@ public class MergeNodeReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public MergeNodeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public MergeNodeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -135,6 +138,8 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MergeNode", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -163,7 +168,7 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -308,6 +313,10 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -324,13 +333,17 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -384,7 +397,14 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -408,7 +428,14 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -420,7 +447,14 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -432,7 +466,14 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -444,7 +485,14 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -456,7 +504,14 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -468,7 +523,14 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -480,7 +542,14 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -492,7 +561,14 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -504,7 +580,14 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -516,7 +599,14 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -528,7 +618,14 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -540,7 +637,14 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -554,12 +658,18 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -575,12 +685,18 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -594,12 +710,23 @@ public override IMergeNode Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MergeNode at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -649,6 +776,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MergeNode", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -677,7 +806,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -822,6 +951,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -838,13 +971,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -898,7 +1035,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -922,7 +1066,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -934,7 +1085,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -946,7 +1104,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -958,7 +1123,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -970,7 +1142,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -982,7 +1161,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -994,7 +1180,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1006,7 +1199,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1018,7 +1218,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1030,7 +1237,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1042,7 +1256,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1054,7 +1275,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1068,12 +1296,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1089,12 +1323,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1108,12 +1348,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MergeNode at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetaclassReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetaclassReader.cs index de6ddfe7f..aaefe6fe6 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetaclassReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetaclassReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -41,6 +42,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Metadata; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -65,7 +67,8 @@ public class MetaclassReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public MetaclassReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public MetaclassReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +114,8 @@ public override IMetaclass Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Metaclass", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -184,6 +189,10 @@ public override IMetaclass Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -200,6 +209,10 @@ public override IMetaclass Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -262,7 +275,14 @@ public override IMetaclass Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -274,7 +294,14 @@ public override IMetaclass Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -286,7 +313,14 @@ public override IMetaclass Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -300,12 +334,18 @@ public override IMetaclass Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -321,12 +361,18 @@ public override IMetaclass Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -334,6 +380,10 @@ public override IMetaclass Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Metaclass at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -383,6 +433,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Metaclass", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -456,6 +508,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -472,6 +528,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -534,7 +594,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -546,7 +613,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -558,7 +632,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -572,12 +653,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -593,12 +680,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -606,6 +699,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Metaclass at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataAccessExpressionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataAccessExpressionReader.cs index 45f863ba8..5d7ba59bb 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataAccessExpressionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataAccessExpressionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class MetadataAccessExpressionReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public MetadataAccessExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public MetadataAccessExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MetadataAccessExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -275,6 +280,10 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -291,6 +300,10 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -341,7 +354,14 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -365,7 +385,14 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -377,7 +404,14 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -389,7 +423,14 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -401,7 +442,14 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -413,7 +461,14 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -425,7 +480,14 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -437,7 +499,14 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -449,7 +518,14 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -461,7 +537,14 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -473,7 +556,14 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -485,7 +575,14 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -499,12 +596,18 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -520,12 +623,18 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -533,6 +642,10 @@ public override IMetadataAccessExpression Read(XmlReader xmiReader, Uri currentL break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MetadataAccessExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -582,6 +695,8 @@ public override async Task ReadAsync(XmlReader xmiRea this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MetadataAccessExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -610,7 +725,7 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -745,6 +860,10 @@ public override async Task ReadAsync(XmlReader xmiRea { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -761,6 +880,10 @@ public override async Task ReadAsync(XmlReader xmiRea { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -811,7 +934,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -835,7 +965,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -847,7 +984,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -859,7 +1003,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -871,7 +1022,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -883,7 +1041,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -895,7 +1060,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -907,7 +1079,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -919,7 +1098,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -931,7 +1117,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -943,7 +1136,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -955,7 +1155,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -969,12 +1176,18 @@ public override async Task ReadAsync(XmlReader xmiRea { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -990,12 +1203,18 @@ public override async Task ReadAsync(XmlReader xmiRea { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1003,6 +1222,10 @@ public override async Task ReadAsync(XmlReader xmiRea break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MetadataAccessExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataDefinitionReader.cs index 56f92a2f3..2704b3717 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -62,6 +63,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -86,7 +88,8 @@ public class MetadataDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public MetadataDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public MetadataDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -132,6 +135,8 @@ public override IMetadataDefinition Read(XmlReader xmiReader, Uri currentLocatio this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MetadataDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -225,6 +230,10 @@ public override IMetadataDefinition Read(XmlReader xmiReader, Uri currentLocatio { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -241,6 +250,10 @@ public override IMetadataDefinition Read(XmlReader xmiReader, Uri currentLocatio { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -303,7 +316,14 @@ public override IMetadataDefinition Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -315,7 +335,14 @@ public override IMetadataDefinition Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -327,7 +354,14 @@ public override IMetadataDefinition Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -339,7 +373,14 @@ public override IMetadataDefinition Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -351,7 +392,14 @@ public override IMetadataDefinition Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -365,12 +413,18 @@ public override IMetadataDefinition Read(XmlReader xmiReader, Uri currentLocatio { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -386,12 +440,18 @@ public override IMetadataDefinition Read(XmlReader xmiReader, Uri currentLocatio { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -399,6 +459,10 @@ public override IMetadataDefinition Read(XmlReader xmiReader, Uri currentLocatio break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MetadataDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -448,6 +512,8 @@ public override async Task ReadAsync(XmlReader xmiReader, U this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MetadataDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -541,6 +607,10 @@ public override async Task ReadAsync(XmlReader xmiReader, U { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -557,6 +627,10 @@ public override async Task ReadAsync(XmlReader xmiReader, U { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -619,7 +693,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -631,7 +712,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -643,7 +731,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -655,7 +750,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -667,7 +769,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -681,12 +790,18 @@ public override async Task ReadAsync(XmlReader xmiReader, U { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -702,12 +817,18 @@ public override async Task ReadAsync(XmlReader xmiReader, U { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -715,6 +836,10 @@ public override async Task ReadAsync(XmlReader xmiReader, U break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MetadataDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataFeatureReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataFeatureReader.cs index 7f870e8dd..631f72b62 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataFeatureReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataFeatureReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -40,6 +41,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Metadata; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -64,7 +66,8 @@ public class MetadataFeatureReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public MetadataFeatureReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public MetadataFeatureReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -110,6 +113,8 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MetadataFeature", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -138,7 +143,7 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -273,6 +278,10 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -289,6 +298,10 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -339,7 +352,14 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -363,7 +383,14 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -375,7 +402,14 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -387,7 +421,14 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -399,7 +440,14 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -411,7 +459,14 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -423,7 +478,14 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -435,7 +497,14 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -447,7 +516,14 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -459,7 +535,14 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -471,7 +554,14 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -483,7 +573,14 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -497,12 +594,18 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -518,12 +621,18 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -531,6 +640,10 @@ public override IMetadataFeature Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MetadataFeature at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -580,6 +693,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MetadataFeature", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -608,7 +723,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -743,6 +858,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -759,6 +878,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -809,7 +932,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -833,7 +963,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -845,7 +982,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -857,7 +1001,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -869,7 +1020,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -881,7 +1039,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -893,7 +1058,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -905,7 +1077,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -917,7 +1096,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -929,7 +1115,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -941,7 +1134,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -953,7 +1153,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -967,12 +1174,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -988,12 +1201,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1001,6 +1220,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MetadataFeature at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataUsageReader.cs index 26282f0b3..5c4c43a1b 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MetadataUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class MetadataUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public MetadataUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public MetadataUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MetadataUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override IMetadataUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MetadataUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MetadataUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MetadataUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MultiplicityRangeReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MultiplicityRangeReader.cs index 85f674c48..7e51476b2 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MultiplicityRangeReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MultiplicityRangeReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -41,6 +42,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Multiplicities; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -65,7 +67,8 @@ public class MultiplicityRangeReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public MultiplicityRangeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public MultiplicityRangeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +114,8 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MultiplicityRange", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -139,7 +144,7 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -274,6 +279,10 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -290,6 +299,10 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -340,7 +353,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -364,7 +384,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -376,7 +403,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -388,7 +422,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -400,7 +441,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -412,7 +460,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -424,7 +479,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -436,7 +498,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -448,7 +517,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -460,7 +536,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -472,7 +555,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -484,7 +574,14 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -498,12 +595,18 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -519,12 +622,18 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -532,6 +641,10 @@ public override IMultiplicityRange Read(XmlReader xmiReader, Uri currentLocation break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MultiplicityRange at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -581,6 +694,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "MultiplicityRange", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -609,7 +724,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -744,6 +859,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -760,6 +879,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -810,7 +933,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -834,7 +964,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -846,7 +983,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -858,7 +1002,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -870,7 +1021,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -882,7 +1040,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -894,7 +1059,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -906,7 +1078,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -918,7 +1097,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -930,7 +1116,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -942,7 +1135,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -954,7 +1154,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -968,12 +1175,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -989,12 +1202,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1002,6 +1221,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading MultiplicityRange at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MultiplicityReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MultiplicityReader.cs index 935058c00..09a466431 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MultiplicityReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/MultiplicityReader.cs @@ -33,12 +33,14 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -63,7 +65,8 @@ public class MultiplicityReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public MultiplicityReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public MultiplicityReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -109,6 +112,8 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Multiplicity", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -137,7 +142,7 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -272,6 +277,10 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -288,6 +297,10 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -338,7 +351,14 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -362,7 +382,14 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -374,7 +401,14 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -386,7 +420,14 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -398,7 +439,14 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -410,7 +458,14 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -422,7 +477,14 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -434,7 +496,14 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -446,7 +515,14 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -458,7 +534,14 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -470,7 +553,14 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -482,7 +572,14 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -496,12 +593,18 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -517,12 +620,18 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -530,6 +639,10 @@ public override IMultiplicity Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Multiplicity at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -579,6 +692,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Multiplicity", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -607,7 +722,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -742,6 +857,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -758,6 +877,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -808,7 +931,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -832,7 +962,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -844,7 +981,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -856,7 +1000,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -868,7 +1019,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -880,7 +1038,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -892,7 +1057,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -904,7 +1076,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -916,7 +1095,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -928,7 +1114,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -940,7 +1133,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -952,7 +1152,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -966,12 +1173,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -987,12 +1200,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1000,6 +1219,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Multiplicity at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NamespaceExposeReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NamespaceExposeReader.cs index 3c9bec70b..4fff195f4 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NamespaceExposeReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NamespaceExposeReader.cs @@ -33,11 +33,13 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -62,7 +64,8 @@ public class NamespaceExposeReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public NamespaceExposeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public NamespaceExposeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +111,8 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "NamespaceExpose", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -147,6 +152,10 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedNamespace", importedNamespaceXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'importedNamespace' on element {ElementId}", importedNamespaceXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -201,6 +210,10 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -221,6 +234,10 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -237,6 +254,10 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -247,13 +268,17 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -321,12 +346,18 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var importedNamespaceId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedNamespace", importedNamespaceId); + if (Guid.TryParse(hrefSplit[1], out var importedNamespaceId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedNamespace", importedNamespaceId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'importedNamespace' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var importedNamespaceValue = (INamespace)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var importedNamespaceValue = (INamespace)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ImportedNamespace = importedNamespaceValue; } @@ -340,7 +371,14 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -352,7 +390,14 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -364,7 +409,14 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImportAllValue)) { - poco.IsImportAll = bool.Parse(isImportAllValue); + if (bool.TryParse(isImportAllValue, out var isImportAllValueAsBool)) + { + poco.IsImportAll = isImportAllValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImportAll' on element {ElementId}", isImportAllValue, poco.Id); + } } break; @@ -376,7 +428,14 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isRecursiveValue)) { - poco.IsRecursive = bool.Parse(isRecursiveValue); + if (bool.TryParse(isRecursiveValue, out var isRecursiveValueAsBool)) + { + poco.IsRecursive = isRecursiveValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isRecursive' on element {ElementId}", isRecursiveValue, poco.Id); + } } break; @@ -390,12 +449,18 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -411,12 +476,18 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -432,12 +503,18 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -453,12 +530,18 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -472,12 +555,23 @@ public override INamespaceExpose Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading NamespaceExpose at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -527,6 +621,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "NamespaceExpose", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -566,6 +662,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedNamespace", importedNamespaceXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'importedNamespace' on element {ElementId}", importedNamespaceXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -620,6 +720,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -640,6 +744,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -656,6 +764,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -666,13 +778,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -740,12 +856,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var importedNamespaceId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedNamespace", importedNamespaceId); + if (Guid.TryParse(hrefSplit[1], out var importedNamespaceId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedNamespace", importedNamespaceId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'importedNamespace' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var importedNamespaceValue = (INamespace)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var importedNamespaceValue = (INamespace)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ImportedNamespace = importedNamespaceValue; } @@ -759,7 +881,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -771,7 +900,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -783,7 +919,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImportAllValue)) { - poco.IsImportAll = bool.Parse(isImportAllValue); + if (bool.TryParse(isImportAllValue, out var isImportAllValueAsBool)) + { + poco.IsImportAll = isImportAllValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImportAll' on element {ElementId}", isImportAllValue, poco.Id); + } } break; @@ -795,7 +938,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isRecursiveValue)) { - poco.IsRecursive = bool.Parse(isRecursiveValue); + if (bool.TryParse(isRecursiveValue, out var isRecursiveValueAsBool)) + { + poco.IsRecursive = isRecursiveValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isRecursive' on element {ElementId}", isRecursiveValue, poco.Id); + } } break; @@ -809,12 +959,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -830,12 +986,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -851,12 +1013,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -872,12 +1040,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -891,12 +1065,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading NamespaceExpose at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NamespaceImportReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NamespaceImportReader.cs index 351693382..d2e95456e 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NamespaceImportReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NamespaceImportReader.cs @@ -33,10 +33,12 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -61,7 +63,8 @@ public class NamespaceImportReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public NamespaceImportReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public NamespaceImportReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -107,6 +110,8 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "NamespaceImport", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -146,6 +151,10 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedNamespace", importedNamespaceXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'importedNamespace' on element {ElementId}", importedNamespaceXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -200,6 +209,10 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -220,6 +233,10 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -236,6 +253,10 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -246,13 +267,17 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -320,12 +345,18 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var importedNamespaceId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedNamespace", importedNamespaceId); + if (Guid.TryParse(hrefSplit[1], out var importedNamespaceId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedNamespace", importedNamespaceId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'importedNamespace' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var importedNamespaceValue = (INamespace)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var importedNamespaceValue = (INamespace)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ImportedNamespace = importedNamespaceValue; } @@ -339,7 +370,14 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -351,7 +389,14 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -363,7 +408,14 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImportAllValue)) { - poco.IsImportAll = bool.Parse(isImportAllValue); + if (bool.TryParse(isImportAllValue, out var isImportAllValueAsBool)) + { + poco.IsImportAll = isImportAllValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImportAll' on element {ElementId}", isImportAllValue, poco.Id); + } } break; @@ -375,7 +427,14 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isRecursiveValue)) { - poco.IsRecursive = bool.Parse(isRecursiveValue); + if (bool.TryParse(isRecursiveValue, out var isRecursiveValueAsBool)) + { + poco.IsRecursive = isRecursiveValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isRecursive' on element {ElementId}", isRecursiveValue, poco.Id); + } } break; @@ -389,12 +448,18 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -410,12 +475,18 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -431,12 +502,18 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -452,12 +529,18 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -471,12 +554,23 @@ public override INamespaceImport Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading NamespaceImport at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -526,6 +620,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "NamespaceImport", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -565,6 +661,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedNamespace", importedNamespaceXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'importedNamespace' on element {ElementId}", importedNamespaceXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -619,6 +719,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -639,6 +743,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -655,6 +763,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -665,13 +777,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -739,12 +855,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var importedNamespaceId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedNamespace", importedNamespaceId); + if (Guid.TryParse(hrefSplit[1], out var importedNamespaceId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "importedNamespace", importedNamespaceId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'importedNamespace' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var importedNamespaceValue = (INamespace)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var importedNamespaceValue = (INamespace)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ImportedNamespace = importedNamespaceValue; } @@ -758,7 +880,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -770,7 +899,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -782,7 +918,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImportAllValue)) { - poco.IsImportAll = bool.Parse(isImportAllValue); + if (bool.TryParse(isImportAllValue, out var isImportAllValueAsBool)) + { + poco.IsImportAll = isImportAllValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImportAll' on element {ElementId}", isImportAllValue, poco.Id); + } } break; @@ -794,7 +937,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isRecursiveValue)) { - poco.IsRecursive = bool.Parse(isRecursiveValue); + if (bool.TryParse(isRecursiveValue, out var isRecursiveValueAsBool)) + { + poco.IsRecursive = isRecursiveValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isRecursive' on element {ElementId}", isRecursiveValue, poco.Id); + } } break; @@ -808,12 +958,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -829,12 +985,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -850,12 +1012,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -871,12 +1039,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -890,12 +1064,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading NamespaceImport at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NamespaceReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NamespaceReader.cs index c3f99b707..5d09fe3fa 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NamespaceReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NamespaceReader.cs @@ -33,9 +33,11 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -60,7 +62,8 @@ public class NamespaceReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public NamespaceReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public NamespaceReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -106,6 +109,8 @@ public override INamespace Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Namespace", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -159,6 +164,10 @@ public override INamespace Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -175,6 +184,10 @@ public override INamespace Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -237,7 +250,14 @@ public override INamespace Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -251,12 +271,18 @@ public override INamespace Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -272,12 +298,18 @@ public override INamespace Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -285,6 +317,10 @@ public override INamespace Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Namespace at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -334,6 +370,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Namespace", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -387,6 +425,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -403,6 +445,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -465,7 +511,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -479,12 +532,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -500,12 +559,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -513,6 +578,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Namespace at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NullExpressionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NullExpressionReader.cs index 4e9cf84f6..0d2bdaf75 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NullExpressionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/NullExpressionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class NullExpressionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public NullExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public NullExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "NullExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -275,6 +280,10 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -291,6 +300,10 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -341,7 +354,14 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -365,7 +385,14 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -377,7 +404,14 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -389,7 +423,14 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -401,7 +442,14 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -413,7 +461,14 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -425,7 +480,14 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -437,7 +499,14 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -449,7 +518,14 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -461,7 +537,14 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -473,7 +556,14 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -485,7 +575,14 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -499,12 +596,18 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -520,12 +623,18 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -533,6 +642,10 @@ public override INullExpression Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading NullExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -582,6 +695,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "NullExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -610,7 +725,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -745,6 +860,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -761,6 +880,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -811,7 +934,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -835,7 +965,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -847,7 +984,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -859,7 +1003,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -871,7 +1022,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -883,7 +1041,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -895,7 +1060,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -907,7 +1079,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -919,7 +1098,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -931,7 +1117,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -943,7 +1136,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -955,7 +1155,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -969,12 +1176,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -990,12 +1203,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1003,6 +1222,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading NullExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ObjectiveMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ObjectiveMembershipReader.cs index 96d216cf0..f6b71acf9 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ObjectiveMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ObjectiveMembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -41,6 +42,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.Requirements; using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -65,7 +67,8 @@ public class ObjectiveMembershipReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ObjectiveMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ObjectiveMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +114,8 @@ public override IObjectiveMembership Read(XmlReader xmiReader, Uri currentLocati this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ObjectiveMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -174,6 +179,10 @@ public override IObjectiveMembership Read(XmlReader xmiReader, Uri currentLocati { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -194,6 +203,10 @@ public override IObjectiveMembership Read(XmlReader xmiReader, Uri currentLocati { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -210,6 +223,10 @@ public override IObjectiveMembership Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -220,13 +237,17 @@ public override IObjectiveMembership Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -292,7 +313,14 @@ public override IObjectiveMembership Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -304,7 +332,14 @@ public override IObjectiveMembership Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -318,12 +353,18 @@ public override IObjectiveMembership Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -339,12 +380,18 @@ public override IObjectiveMembership Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -360,12 +407,18 @@ public override IObjectiveMembership Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -381,12 +434,18 @@ public override IObjectiveMembership Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -400,12 +459,23 @@ public override IObjectiveMembership Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ObjectiveMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -455,6 +525,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ObjectiveMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -518,6 +590,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -538,6 +614,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -554,6 +634,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -564,13 +648,17 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -636,7 +724,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -648,7 +743,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -662,12 +764,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -683,12 +791,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -704,12 +818,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -725,12 +845,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -744,12 +870,23 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ObjectiveMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OccurrenceDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OccurrenceDefinitionReader.cs index 003c2b789..296a44eb3 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OccurrenceDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OccurrenceDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -62,6 +63,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -86,7 +88,8 @@ public class OccurrenceDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public OccurrenceDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public OccurrenceDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -132,6 +135,8 @@ public override IOccurrenceDefinition Read(XmlReader xmiReader, Uri currentLocat this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "OccurrenceDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -225,6 +230,10 @@ public override IOccurrenceDefinition Read(XmlReader xmiReader, Uri currentLocat { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -241,6 +250,10 @@ public override IOccurrenceDefinition Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -303,7 +316,14 @@ public override IOccurrenceDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -315,7 +335,14 @@ public override IOccurrenceDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -327,7 +354,14 @@ public override IOccurrenceDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -339,7 +373,14 @@ public override IOccurrenceDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -351,7 +392,14 @@ public override IOccurrenceDefinition Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -365,12 +413,18 @@ public override IOccurrenceDefinition Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -386,12 +440,18 @@ public override IOccurrenceDefinition Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -399,6 +459,10 @@ public override IOccurrenceDefinition Read(XmlReader xmiReader, Uri currentLocat break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading OccurrenceDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -448,6 +512,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "OccurrenceDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -541,6 +607,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -557,6 +627,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -619,7 +693,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -631,7 +712,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -643,7 +731,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -655,7 +750,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -667,7 +769,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -681,12 +790,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -702,12 +817,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -715,6 +836,10 @@ public override async Task ReadAsync(XmlReader xmiReader, break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading OccurrenceDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OccurrenceUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OccurrenceUsageReader.cs index 0bfff368b..b02b211e9 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OccurrenceUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OccurrenceUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -64,6 +65,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -88,7 +90,8 @@ public class OccurrenceUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public OccurrenceUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public OccurrenceUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -134,6 +137,8 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "OccurrenceUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -162,7 +167,7 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -307,6 +312,10 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -323,13 +332,17 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -383,7 +396,14 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -407,7 +427,14 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -419,7 +446,14 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -431,7 +465,14 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -443,7 +484,14 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -455,7 +503,14 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -467,7 +522,14 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -479,7 +541,14 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -491,7 +560,14 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -503,7 +579,14 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -515,7 +598,14 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -527,7 +617,14 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -539,7 +636,14 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -553,12 +657,18 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -574,12 +684,18 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -593,12 +709,23 @@ public override IOccurrenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading OccurrenceUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -648,6 +775,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "OccurrenceUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -676,7 +805,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -821,6 +950,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -837,13 +970,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -897,7 +1034,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -921,7 +1065,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -933,7 +1084,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -945,7 +1103,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -957,7 +1122,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -969,7 +1141,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -981,7 +1160,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -993,7 +1179,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1005,7 +1198,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1017,7 +1217,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1029,7 +1236,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1041,7 +1255,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1053,7 +1274,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1067,12 +1295,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1088,12 +1322,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1107,12 +1347,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading OccurrenceUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OperatorExpressionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OperatorExpressionReader.cs index 3220900c9..0542cc3de 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OperatorExpressionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OperatorExpressionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class OperatorExpressionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public OperatorExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public OperatorExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "OperatorExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -282,6 +287,10 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -298,6 +307,10 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -348,7 +361,14 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -372,7 +392,14 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -384,7 +411,14 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -396,7 +430,14 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -408,7 +449,14 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -420,7 +468,14 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -432,7 +487,14 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -444,7 +506,14 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -456,7 +525,14 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -468,7 +544,14 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -480,7 +563,14 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -492,7 +582,14 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -518,12 +615,18 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -539,12 +642,18 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -552,6 +661,10 @@ public override IOperatorExpression Read(XmlReader xmiReader, Uri currentLocatio break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading OperatorExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -601,6 +714,8 @@ public override async Task ReadAsync(XmlReader xmiReader, U this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "OperatorExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -629,7 +744,7 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -771,6 +886,10 @@ public override async Task ReadAsync(XmlReader xmiReader, U { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -787,6 +906,10 @@ public override async Task ReadAsync(XmlReader xmiReader, U { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -837,7 +960,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -861,7 +991,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -873,7 +1010,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -885,7 +1029,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -897,7 +1048,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -909,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -921,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -933,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -945,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -957,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -969,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -981,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1007,12 +1214,18 @@ public override async Task ReadAsync(XmlReader xmiReader, U { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1028,12 +1241,18 @@ public override async Task ReadAsync(XmlReader xmiReader, U { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1041,6 +1260,10 @@ public override async Task ReadAsync(XmlReader xmiReader, U break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading OperatorExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OwningMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OwningMembershipReader.cs index f0bc91898..b78e51826 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OwningMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/OwningMembershipReader.cs @@ -33,10 +33,12 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -61,7 +63,8 @@ public class OwningMembershipReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public OwningMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public OwningMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -107,6 +110,8 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "OwningMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -170,6 +175,10 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -190,6 +199,10 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -206,6 +219,10 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -216,13 +233,17 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -288,7 +309,14 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -300,7 +328,14 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -314,12 +349,18 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -335,12 +376,18 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -356,12 +403,18 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -377,12 +430,18 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -396,12 +455,23 @@ public override IOwningMembership Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading OwningMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -451,6 +521,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "OwningMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -514,6 +586,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -534,6 +610,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -550,6 +630,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -560,13 +644,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -632,7 +720,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -644,7 +739,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -658,12 +760,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -679,12 +787,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -700,12 +814,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -721,12 +841,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -740,12 +866,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading OwningMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PackageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PackageReader.cs index 0bfa3e5dc..3c540a2d3 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PackageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PackageReader.cs @@ -33,11 +33,13 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Kernel.Functions; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Packages; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -62,7 +64,8 @@ public class PackageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public PackageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public PackageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +111,8 @@ public override IPackage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Package", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -161,6 +166,10 @@ public override IPackage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -177,6 +186,10 @@ public override IPackage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -239,7 +252,14 @@ public override IPackage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -253,12 +273,18 @@ public override IPackage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -274,12 +300,18 @@ public override IPackage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -287,6 +319,10 @@ public override IPackage Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Package at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -336,6 +372,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Package", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -389,6 +427,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -405,6 +447,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -467,7 +513,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,12 +534,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -502,12 +561,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -515,6 +580,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentL break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Package at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ParameterMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ParameterMembershipReader.cs index 272a25a82..20a4dd4e9 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ParameterMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ParameterMembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -40,6 +41,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -64,7 +66,8 @@ public class ParameterMembershipReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ParameterMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ParameterMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -110,6 +113,8 @@ public override IParameterMembership Read(XmlReader xmiReader, Uri currentLocati this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ParameterMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -173,6 +178,10 @@ public override IParameterMembership Read(XmlReader xmiReader, Uri currentLocati { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -193,6 +202,10 @@ public override IParameterMembership Read(XmlReader xmiReader, Uri currentLocati { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -209,6 +222,10 @@ public override IParameterMembership Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -219,13 +236,17 @@ public override IParameterMembership Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -291,7 +312,14 @@ public override IParameterMembership Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -303,7 +331,14 @@ public override IParameterMembership Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -317,12 +352,18 @@ public override IParameterMembership Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -338,12 +379,18 @@ public override IParameterMembership Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -359,12 +406,18 @@ public override IParameterMembership Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -380,12 +433,18 @@ public override IParameterMembership Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -399,12 +458,23 @@ public override IParameterMembership Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ParameterMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -454,6 +524,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ParameterMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -517,6 +589,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -537,6 +613,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -553,6 +633,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -563,13 +647,17 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -635,7 +723,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -647,7 +742,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -661,12 +763,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -682,12 +790,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -703,12 +817,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -724,12 +844,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -743,12 +869,23 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ParameterMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PartDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PartDefinitionReader.cs index 8fd555ef6..78adf94e7 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PartDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PartDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -61,6 +62,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -85,7 +87,8 @@ public class PartDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public PartDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public PartDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -131,6 +134,8 @@ public override IPartDefinition Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "PartDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -224,6 +229,10 @@ public override IPartDefinition Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -240,6 +249,10 @@ public override IPartDefinition Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -302,7 +315,14 @@ public override IPartDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -314,7 +334,14 @@ public override IPartDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -326,7 +353,14 @@ public override IPartDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -338,7 +372,14 @@ public override IPartDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -350,7 +391,14 @@ public override IPartDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -364,12 +412,18 @@ public override IPartDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -385,12 +439,18 @@ public override IPartDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -398,6 +458,10 @@ public override IPartDefinition Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading PartDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -447,6 +511,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "PartDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -540,6 +606,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -556,6 +626,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -618,7 +692,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -630,7 +711,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -642,7 +730,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -654,7 +749,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -666,7 +768,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -680,12 +789,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -701,12 +816,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -714,6 +835,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading PartDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PartUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PartUsageReader.cs index cb3b8c47a..0a889a27e 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PartUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PartUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -65,6 +66,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -89,7 +91,8 @@ public class PartUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public PartUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public PartUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -135,6 +138,8 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "PartUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -163,7 +168,7 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -308,6 +313,10 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -324,13 +333,17 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -384,7 +397,14 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -408,7 +428,14 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -420,7 +447,14 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -432,7 +466,14 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -444,7 +485,14 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -456,7 +504,14 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -468,7 +523,14 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -480,7 +542,14 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -492,7 +561,14 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -504,7 +580,14 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -516,7 +599,14 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -528,7 +618,14 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -540,7 +637,14 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -554,12 +658,18 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -575,12 +685,18 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -594,12 +710,23 @@ public override IPartUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading PartUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -649,6 +776,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "PartUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -677,7 +806,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -822,6 +951,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -838,13 +971,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -898,7 +1035,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -922,7 +1066,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -934,7 +1085,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -946,7 +1104,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -958,7 +1123,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -970,7 +1142,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -982,7 +1161,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -994,7 +1180,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1006,7 +1199,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1018,7 +1218,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1030,7 +1237,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1042,7 +1256,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1054,7 +1275,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1068,12 +1296,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1089,12 +1323,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1108,12 +1348,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading PartUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PayloadFeatureReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PayloadFeatureReader.cs index bcecdd87f..438f17d39 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PayloadFeatureReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PayloadFeatureReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -40,6 +41,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Interactions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -64,7 +66,8 @@ public class PayloadFeatureReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public PayloadFeatureReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public PayloadFeatureReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -110,6 +113,8 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "PayloadFeature", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -138,7 +143,7 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -273,6 +278,10 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -289,6 +298,10 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -339,7 +352,14 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -363,7 +383,14 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -375,7 +402,14 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -387,7 +421,14 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -399,7 +440,14 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -411,7 +459,14 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -423,7 +478,14 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -435,7 +497,14 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -447,7 +516,14 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -459,7 +535,14 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -471,7 +554,14 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -483,7 +573,14 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -497,12 +594,18 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -518,12 +621,18 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -531,6 +640,10 @@ public override IPayloadFeature Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading PayloadFeature at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -580,6 +693,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "PayloadFeature", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -608,7 +723,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -743,6 +858,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -759,6 +878,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -809,7 +932,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -833,7 +963,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -845,7 +982,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -857,7 +1001,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -869,7 +1020,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -881,7 +1039,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -893,7 +1058,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -905,7 +1077,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -917,7 +1096,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -929,7 +1115,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -941,7 +1134,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -953,7 +1153,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -967,12 +1174,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -988,12 +1201,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1001,6 +1220,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading PayloadFeature at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PerformActionUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PerformActionUsageReader.cs index a90f7e585..55199b615 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PerformActionUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PerformActionUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -65,6 +66,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -89,7 +91,8 @@ public class PerformActionUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public PerformActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public PerformActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -135,6 +138,8 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "PerformActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -163,7 +168,7 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -308,6 +313,10 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -324,13 +333,17 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -384,7 +397,14 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -408,7 +428,14 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -420,7 +447,14 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -432,7 +466,14 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -444,7 +485,14 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -456,7 +504,14 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -468,7 +523,14 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -480,7 +542,14 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -492,7 +561,14 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -504,7 +580,14 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -516,7 +599,14 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -528,7 +618,14 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -540,7 +637,14 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -554,12 +658,18 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -575,12 +685,18 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -594,12 +710,23 @@ public override IPerformActionUsage Read(XmlReader xmiReader, Uri currentLocatio if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading PerformActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -649,6 +776,8 @@ public override async Task ReadAsync(XmlReader xmiReader, U this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "PerformActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -677,7 +806,7 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -822,6 +951,10 @@ public override async Task ReadAsync(XmlReader xmiReader, U { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -838,13 +971,17 @@ public override async Task ReadAsync(XmlReader xmiReader, U { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -898,7 +1035,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -922,7 +1066,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -934,7 +1085,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -946,7 +1104,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -958,7 +1123,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -970,7 +1142,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -982,7 +1161,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -994,7 +1180,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1006,7 +1199,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1018,7 +1218,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1030,7 +1237,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1042,7 +1256,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1054,7 +1275,14 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1068,12 +1296,18 @@ public override async Task ReadAsync(XmlReader xmiReader, U { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1089,12 +1323,18 @@ public override async Task ReadAsync(XmlReader xmiReader, U { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1108,12 +1348,23 @@ public override async Task ReadAsync(XmlReader xmiReader, U if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading PerformActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PortConjugationReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PortConjugationReader.cs index da6cf3bbb..ed4e6dcc8 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PortConjugationReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PortConjugationReader.cs @@ -33,11 +33,13 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -62,7 +64,8 @@ public class PortConjugationReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public PortConjugationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public PortConjugationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +111,8 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "PortConjugation", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -126,6 +131,10 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedType", conjugatedTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'conjugatedType' on element {ElementId}", conjugatedTypeXmlAttribute, poco.Id); + } } var declaredNameXmlAttribute = xmiReader.GetAttribute("declaredName"); @@ -177,6 +186,10 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "originalPortDefinition", originalPortDefinitionXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'originalPortDefinition' on element {ElementId}", originalPortDefinitionXmlAttribute, poco.Id); + } } var ownedRelatedElementXmlAttribute = xmiReader.GetAttribute("ownedRelatedElement"); @@ -191,6 +204,10 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -211,6 +228,10 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -227,6 +248,10 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -237,6 +262,10 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -265,12 +294,18 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var conjugatedTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedType", conjugatedTypeId); + if (Guid.TryParse(hrefSplit[1], out var conjugatedTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedType", conjugatedTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'conjugatedType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var conjugatedTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var conjugatedTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ConjugatedType = conjugatedTypeValue; } @@ -320,7 +355,14 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -332,7 +374,14 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -346,12 +395,18 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var originalPortDefinitionId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "originalPortDefinition", originalPortDefinitionId); + if (Guid.TryParse(hrefSplit[1], out var originalPortDefinitionId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "originalPortDefinition", originalPortDefinitionId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'originalPortDefinition' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var originalPortDefinitionValue = (IPortDefinition)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var originalPortDefinitionValue = (IPortDefinition)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.OriginalPortDefinition = originalPortDefinitionValue; } @@ -367,12 +422,18 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -388,12 +449,18 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -409,12 +476,18 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -430,12 +503,18 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -443,6 +522,10 @@ public override IPortConjugation Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading PortConjugation at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -492,6 +575,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "PortConjugation", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -510,6 +595,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedType", conjugatedTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'conjugatedType' on element {ElementId}", conjugatedTypeXmlAttribute, poco.Id); + } } var declaredNameXmlAttribute = xmiReader.GetAttribute("declaredName"); @@ -561,6 +650,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "originalPortDefinition", originalPortDefinitionXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'originalPortDefinition' on element {ElementId}", originalPortDefinitionXmlAttribute, poco.Id); + } } var ownedRelatedElementXmlAttribute = xmiReader.GetAttribute("ownedRelatedElement"); @@ -575,6 +668,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -595,6 +692,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -611,6 +712,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -621,6 +726,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -649,12 +758,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var conjugatedTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedType", conjugatedTypeId); + if (Guid.TryParse(hrefSplit[1], out var conjugatedTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "conjugatedType", conjugatedTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'conjugatedType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var conjugatedTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var conjugatedTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ConjugatedType = conjugatedTypeValue; } @@ -704,7 +819,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -716,7 +838,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -730,12 +859,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var originalPortDefinitionId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "originalPortDefinition", originalPortDefinitionId); + if (Guid.TryParse(hrefSplit[1], out var originalPortDefinitionId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "originalPortDefinition", originalPortDefinitionId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'originalPortDefinition' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var originalPortDefinitionValue = (IPortDefinition)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var originalPortDefinitionValue = (IPortDefinition)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.OriginalPortDefinition = originalPortDefinitionValue; } @@ -751,12 +886,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -772,12 +913,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -793,12 +940,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -814,12 +967,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -827,6 +986,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading PortConjugation at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PortDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PortDefinitionReader.cs index 139542364..c32c72414 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PortDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PortDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -62,6 +63,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -86,7 +88,8 @@ public class PortDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public PortDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public PortDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -132,6 +135,8 @@ public override IPortDefinition Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "PortDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -225,6 +230,10 @@ public override IPortDefinition Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -241,6 +250,10 @@ public override IPortDefinition Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -303,7 +316,14 @@ public override IPortDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -315,7 +335,14 @@ public override IPortDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -327,7 +354,14 @@ public override IPortDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -339,7 +373,14 @@ public override IPortDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -351,7 +392,14 @@ public override IPortDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -365,12 +413,18 @@ public override IPortDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -386,12 +440,18 @@ public override IPortDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -399,6 +459,10 @@ public override IPortDefinition Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading PortDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -448,6 +512,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "PortDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -541,6 +607,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -557,6 +627,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -619,7 +693,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -631,7 +712,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -643,7 +731,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -655,7 +750,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -667,7 +769,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -681,12 +790,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -702,12 +817,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -715,6 +836,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading PortDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PortUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PortUsageReader.cs index 2b06f7d45..1b100beaa 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PortUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PortUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -64,6 +65,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -88,7 +90,8 @@ public class PortUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public PortUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public PortUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -134,6 +137,8 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "PortUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -162,7 +167,7 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -307,6 +312,10 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -323,13 +332,17 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -383,7 +396,14 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -407,7 +427,14 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -419,7 +446,14 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -431,7 +465,14 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -443,7 +484,14 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -455,7 +503,14 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -467,7 +522,14 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -479,7 +541,14 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -491,7 +560,14 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -503,7 +579,14 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -515,7 +598,14 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -527,7 +617,14 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -539,7 +636,14 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -553,12 +657,18 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -574,12 +684,18 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -593,12 +709,23 @@ public override IPortUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading PortUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -648,6 +775,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "PortUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -676,7 +805,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -821,6 +950,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -837,13 +970,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -897,7 +1034,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -921,7 +1065,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -933,7 +1084,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -945,7 +1103,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -957,7 +1122,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -969,7 +1141,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -981,7 +1160,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -993,7 +1179,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1005,7 +1198,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1017,7 +1217,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1029,7 +1236,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1041,7 +1255,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1053,7 +1274,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1067,12 +1295,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1088,12 +1322,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1107,12 +1347,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading PortUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PredicateReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PredicateReader.cs index 2c792dda1..8d2e26b50 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PredicateReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/PredicateReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -41,6 +42,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -65,7 +67,8 @@ public class PredicateReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public PredicateReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public PredicateReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +114,8 @@ public override IPredicate Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Predicate", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -184,6 +189,10 @@ public override IPredicate Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -200,6 +209,10 @@ public override IPredicate Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -262,7 +275,14 @@ public override IPredicate Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -274,7 +294,14 @@ public override IPredicate Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -286,7 +313,14 @@ public override IPredicate Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -300,12 +334,18 @@ public override IPredicate Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -321,12 +361,18 @@ public override IPredicate Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -334,6 +380,10 @@ public override IPredicate Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Predicate at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -383,6 +433,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Predicate", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -456,6 +508,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -472,6 +528,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -534,7 +594,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -546,7 +613,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -558,7 +632,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -572,12 +653,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -593,12 +680,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -606,6 +699,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Predicate at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RedefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RedefinitionReader.cs index c4214289e..5ec08db8e 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RedefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RedefinitionReader.cs @@ -33,11 +33,13 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -62,7 +64,8 @@ public class RedefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public RedefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public RedefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +111,8 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Redefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -171,6 +176,10 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -191,6 +200,10 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -207,6 +220,10 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -217,6 +234,10 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var redefinedFeatureXmlAttribute = xmiReader.GetAttribute("redefinedFeature"); @@ -227,6 +248,10 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "redefinedFeature", redefinedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'redefinedFeature' on element {ElementId}", redefinedFeatureXmlAttribute, poco.Id); + } } var redefiningFeatureXmlAttribute = xmiReader.GetAttribute("redefiningFeature"); @@ -237,6 +262,10 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "redefiningFeature", redefiningFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'redefiningFeature' on element {ElementId}", redefiningFeatureXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -299,7 +328,14 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -311,7 +347,14 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -325,12 +368,18 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -346,12 +395,18 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -367,12 +422,18 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -388,12 +449,18 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -409,12 +476,18 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var redefinedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "redefinedFeature", redefinedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var redefinedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "redefinedFeature", redefinedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'redefinedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var redefinedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var redefinedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.RedefinedFeature = redefinedFeatureValue; } @@ -430,12 +503,18 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var redefiningFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "redefiningFeature", redefiningFeatureId); + if (Guid.TryParse(hrefSplit[1], out var redefiningFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "redefiningFeature", redefiningFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'redefiningFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var redefiningFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var redefiningFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.RedefiningFeature = redefiningFeatureValue; } @@ -443,6 +522,10 @@ public override IRedefinition Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Redefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -492,6 +575,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Redefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -555,6 +640,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -575,6 +664,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -591,6 +684,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -601,6 +698,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var redefinedFeatureXmlAttribute = xmiReader.GetAttribute("redefinedFeature"); @@ -611,6 +712,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "redefinedFeature", redefinedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'redefinedFeature' on element {ElementId}", redefinedFeatureXmlAttribute, poco.Id); + } } var redefiningFeatureXmlAttribute = xmiReader.GetAttribute("redefiningFeature"); @@ -621,6 +726,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "redefiningFeature", redefiningFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'redefiningFeature' on element {ElementId}", redefiningFeatureXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -683,7 +792,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -695,7 +811,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -709,12 +832,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -730,12 +859,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -751,12 +886,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -772,12 +913,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -793,12 +940,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var redefinedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "redefinedFeature", redefinedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var redefinedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "redefinedFeature", redefinedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'redefinedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var redefinedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var redefinedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.RedefinedFeature = redefinedFeatureValue; } @@ -814,12 +967,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var redefiningFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "redefiningFeature", redefiningFeatureId); + if (Guid.TryParse(hrefSplit[1], out var redefiningFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "redefiningFeature", redefiningFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'redefiningFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var redefiningFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var redefiningFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.RedefiningFeature = redefiningFeatureValue; } @@ -827,6 +986,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Redefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ReferenceSubsettingReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ReferenceSubsettingReader.cs index 76d4b283b..8d10b222d 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ReferenceSubsettingReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ReferenceSubsettingReader.cs @@ -33,11 +33,13 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -62,7 +64,8 @@ public class ReferenceSubsettingReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ReferenceSubsettingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ReferenceSubsettingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +111,8 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ReferenceSubsetting", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -171,6 +176,10 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -191,6 +200,10 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -207,6 +220,10 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -217,6 +234,10 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var referencedFeatureXmlAttribute = xmiReader.GetAttribute("referencedFeature"); @@ -227,6 +248,10 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "referencedFeature", referencedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'referencedFeature' on element {ElementId}", referencedFeatureXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -289,7 +314,14 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -301,7 +333,14 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -315,12 +354,18 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -336,12 +381,18 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -357,12 +408,18 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -378,12 +435,18 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -399,12 +462,18 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var referencedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "referencedFeature", referencedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var referencedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "referencedFeature", referencedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'referencedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var referencedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var referencedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ReferencedFeature = referencedFeatureValue; } @@ -412,6 +481,10 @@ public override IReferenceSubsetting Read(XmlReader xmiReader, Uri currentLocati break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ReferenceSubsetting at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -461,6 +534,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ReferenceSubsetting", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -524,6 +599,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -544,6 +623,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -560,6 +643,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -570,6 +657,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var referencedFeatureXmlAttribute = xmiReader.GetAttribute("referencedFeature"); @@ -580,6 +671,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "referencedFeature", referencedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'referencedFeature' on element {ElementId}", referencedFeatureXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -642,7 +737,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -654,7 +756,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -668,12 +777,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -689,12 +804,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -710,12 +831,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -731,12 +858,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -752,12 +885,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var referencedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "referencedFeature", referencedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var referencedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "referencedFeature", referencedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'referencedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var referencedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var referencedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.ReferencedFeature = referencedFeatureValue; } @@ -765,6 +904,10 @@ public override async Task ReadAsync(XmlReader xmiReader, break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ReferenceSubsetting at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ReferenceUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ReferenceUsageReader.cs index baa9bd486..a0ecc16af 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ReferenceUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ReferenceUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; @@ -62,6 +63,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -86,7 +88,8 @@ public class ReferenceUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ReferenceUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ReferenceUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -132,6 +135,8 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ReferenceUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -160,7 +165,7 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -295,6 +300,10 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -311,6 +320,10 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -361,7 +374,14 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -385,7 +405,14 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -397,7 +424,14 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -409,7 +443,14 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -421,7 +462,14 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -433,7 +481,14 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -445,7 +500,14 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -457,7 +519,14 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -469,7 +538,14 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -481,7 +557,14 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -493,7 +576,14 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -505,7 +595,14 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -519,12 +616,18 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -540,12 +643,18 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -553,6 +662,10 @@ public override IReferenceUsage Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ReferenceUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -602,6 +715,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ReferenceUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -630,7 +745,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -765,6 +880,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -781,6 +900,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -831,7 +954,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -855,7 +985,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -867,7 +1004,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -879,7 +1023,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -891,7 +1042,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -903,7 +1061,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -915,7 +1080,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -927,7 +1099,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -939,7 +1118,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -951,7 +1137,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -963,7 +1156,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -975,7 +1175,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -989,12 +1196,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1010,12 +1223,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1023,6 +1242,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ReferenceUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RenderingDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RenderingDefinitionReader.cs index 82678661d..0b1259b38 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RenderingDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RenderingDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -61,6 +62,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.UseCases; using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -85,7 +87,8 @@ public class RenderingDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public RenderingDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public RenderingDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -131,6 +134,8 @@ public override IRenderingDefinition Read(XmlReader xmiReader, Uri currentLocati this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "RenderingDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -224,6 +229,10 @@ public override IRenderingDefinition Read(XmlReader xmiReader, Uri currentLocati { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -240,6 +249,10 @@ public override IRenderingDefinition Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -302,7 +315,14 @@ public override IRenderingDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -314,7 +334,14 @@ public override IRenderingDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -326,7 +353,14 @@ public override IRenderingDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -338,7 +372,14 @@ public override IRenderingDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -350,7 +391,14 @@ public override IRenderingDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -364,12 +412,18 @@ public override IRenderingDefinition Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -385,12 +439,18 @@ public override IRenderingDefinition Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -398,6 +458,10 @@ public override IRenderingDefinition Read(XmlReader xmiReader, Uri currentLocati break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading RenderingDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -447,6 +511,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "RenderingDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -540,6 +606,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -556,6 +626,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -618,7 +692,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -630,7 +711,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -642,7 +730,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -654,7 +749,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -666,7 +768,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -680,12 +789,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -701,12 +816,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -714,6 +835,10 @@ public override async Task ReadAsync(XmlReader xmiReader, break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading RenderingDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RenderingUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RenderingUsageReader.cs index ba26737ee..1fd9e6818 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RenderingUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RenderingUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -65,6 +66,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.UseCases; using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -89,7 +91,8 @@ public class RenderingUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public RenderingUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public RenderingUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -135,6 +138,8 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "RenderingUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -163,7 +168,7 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -308,6 +313,10 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -324,13 +333,17 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -384,7 +397,14 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -408,7 +428,14 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -420,7 +447,14 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -432,7 +466,14 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -444,7 +485,14 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -456,7 +504,14 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -468,7 +523,14 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -480,7 +542,14 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -492,7 +561,14 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -504,7 +580,14 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -516,7 +599,14 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -528,7 +618,14 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -540,7 +637,14 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -554,12 +658,18 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -575,12 +685,18 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -594,12 +710,23 @@ public override IRenderingUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading RenderingUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -649,6 +776,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "RenderingUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -677,7 +806,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -822,6 +951,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -838,13 +971,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -898,7 +1035,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -922,7 +1066,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -934,7 +1085,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -946,7 +1104,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -958,7 +1123,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -970,7 +1142,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -982,7 +1161,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -994,7 +1180,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1006,7 +1199,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1018,7 +1218,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1030,7 +1237,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1042,7 +1256,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1054,7 +1275,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1068,12 +1296,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1089,12 +1323,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1108,12 +1348,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading RenderingUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementConstraintMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementConstraintMembershipReader.cs index 4e2faca30..282038347 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementConstraintMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementConstraintMembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.Systems.Requirements; using SysML2.NET.Core.POCO.Core.Features; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.Constraints; using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class RequirementConstraintMembershipReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public RequirementConstraintMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public RequirementConstraintMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override IRequirementConstraintMembership Read(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "RequirementConstraintMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -167,7 +172,7 @@ public override IRequirementConstraintMembership Read(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(kindXmlAttribute)) { - if (Enum.TryParse(kindXmlAttribute, true, out RequirementConstraintKind kindXmlAttributeAsEnum)) + if (RequirementConstraintKindProvider.TryParse(kindXmlAttribute.AsSpan(), out var kindXmlAttributeAsEnum)) { poco.Kind = kindXmlAttributeAsEnum; } @@ -185,6 +190,10 @@ public override IRequirementConstraintMembership Read(XmlReader xmiReader, Uri c { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -205,6 +214,10 @@ public override IRequirementConstraintMembership Read(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -221,6 +234,10 @@ public override IRequirementConstraintMembership Read(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -231,13 +248,17 @@ public override IRequirementConstraintMembership Read(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -303,7 +324,14 @@ public override IRequirementConstraintMembership Read(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -315,7 +343,14 @@ public override IRequirementConstraintMembership Read(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -327,7 +362,14 @@ public override IRequirementConstraintMembership Read(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(kindValue)) { - poco.Kind = (RequirementConstraintKind)Enum.Parse(typeof(RequirementConstraintKind), kindValue, true); + if (RequirementConstraintKindProvider.TryParse(kindValue.AsSpan(), out var kindValueAsEnum)) + { + poco.Kind = kindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'kind' on element {ElementId}", kindValue, poco.Id); + } } break; @@ -341,12 +383,18 @@ public override IRequirementConstraintMembership Read(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -362,12 +410,18 @@ public override IRequirementConstraintMembership Read(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -383,12 +437,18 @@ public override IRequirementConstraintMembership Read(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -404,12 +464,18 @@ public override IRequirementConstraintMembership Read(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -423,12 +489,23 @@ public override IRequirementConstraintMembership Read(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading RequirementConstraintMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -478,6 +555,8 @@ public override async Task ReadAsync(XmlReader this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "RequirementConstraintMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -533,7 +612,7 @@ public override async Task ReadAsync(XmlReader if (!string.IsNullOrWhiteSpace(kindXmlAttribute)) { - if (Enum.TryParse(kindXmlAttribute, true, out RequirementConstraintKind kindXmlAttributeAsEnum)) + if (RequirementConstraintKindProvider.TryParse(kindXmlAttribute.AsSpan(), out var kindXmlAttributeAsEnum)) { poco.Kind = kindXmlAttributeAsEnum; } @@ -551,6 +630,10 @@ public override async Task ReadAsync(XmlReader { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -571,6 +654,10 @@ public override async Task ReadAsync(XmlReader { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -587,6 +674,10 @@ public override async Task ReadAsync(XmlReader { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -597,13 +688,17 @@ public override async Task ReadAsync(XmlReader { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -669,7 +764,14 @@ public override async Task ReadAsync(XmlReader if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -681,7 +783,14 @@ public override async Task ReadAsync(XmlReader if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -693,7 +802,14 @@ public override async Task ReadAsync(XmlReader if (!string.IsNullOrWhiteSpace(kindValue)) { - poco.Kind = (RequirementConstraintKind)Enum.Parse(typeof(RequirementConstraintKind), kindValue, true); + if (RequirementConstraintKindProvider.TryParse(kindValue.AsSpan(), out var kindValueAsEnum)) + { + poco.Kind = kindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'kind' on element {ElementId}", kindValue, poco.Id); + } } break; @@ -707,12 +823,18 @@ public override async Task ReadAsync(XmlReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -728,12 +850,18 @@ public override async Task ReadAsync(XmlReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -749,12 +877,18 @@ public override async Task ReadAsync(XmlReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -770,12 +904,18 @@ public override async Task ReadAsync(XmlReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -789,12 +929,23 @@ public override async Task ReadAsync(XmlReader if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading RequirementConstraintMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementDefinitionReader.cs index 50062fe29..2f0dc79b1 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -63,6 +64,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -87,7 +89,8 @@ public class RequirementDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public RequirementDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public RequirementDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -133,6 +136,8 @@ public override IRequirementDefinition Read(XmlReader xmiReader, Uri currentLoca this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "RequirementDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -219,6 +224,10 @@ public override IRequirementDefinition Read(XmlReader xmiReader, Uri currentLoca { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -235,6 +244,10 @@ public override IRequirementDefinition Read(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var reqIdXmlAttribute = xmiReader.GetAttribute("reqId"); @@ -292,7 +305,14 @@ public override IRequirementDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -304,7 +324,14 @@ public override IRequirementDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -316,7 +343,14 @@ public override IRequirementDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -328,7 +362,14 @@ public override IRequirementDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -340,7 +381,14 @@ public override IRequirementDefinition Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -354,12 +402,18 @@ public override IRequirementDefinition Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -375,12 +429,18 @@ public override IRequirementDefinition Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -400,6 +460,10 @@ public override IRequirementDefinition Read(XmlReader xmiReader, Uri currentLoca break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading RequirementDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -449,6 +513,8 @@ public override async Task ReadAsync(XmlReader xmiReader this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "RequirementDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -535,6 +601,10 @@ public override async Task ReadAsync(XmlReader xmiReader { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -551,6 +621,10 @@ public override async Task ReadAsync(XmlReader xmiReader { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var reqIdXmlAttribute = xmiReader.GetAttribute("reqId"); @@ -608,7 +682,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -620,7 +701,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -632,7 +720,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -644,7 +739,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -656,7 +758,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -670,12 +779,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -691,12 +806,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -716,6 +837,10 @@ public override async Task ReadAsync(XmlReader xmiReader break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading RequirementDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementUsageReader.cs index 1d7fbe4d0..1c8e6f491 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class RequirementUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public RequirementUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public RequirementUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "RequirementUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -157,7 +162,7 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -302,6 +307,10 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -318,13 +327,17 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -373,7 +386,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -397,7 +417,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -409,7 +436,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -421,7 +455,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -433,7 +474,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -445,7 +493,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -457,7 +512,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -469,7 +531,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -481,7 +550,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -493,7 +569,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -505,7 +588,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -517,7 +607,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -529,7 +626,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -543,12 +647,18 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -564,12 +674,18 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -583,7 +699,14 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; @@ -601,6 +724,10 @@ public override IRequirementUsage Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading RequirementUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "RequirementUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -671,7 +800,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -816,6 +945,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -832,13 +965,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -887,7 +1024,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -911,7 +1055,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -923,7 +1074,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -935,7 +1093,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -947,7 +1112,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -959,7 +1131,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -971,7 +1150,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -983,7 +1169,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -995,7 +1188,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1007,7 +1207,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1019,7 +1226,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1031,7 +1245,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1043,7 +1264,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1057,12 +1285,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1078,12 +1312,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1097,7 +1337,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; @@ -1115,6 +1362,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading RequirementUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementVerificationMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementVerificationMembershipReader.cs index 508ec542c..ef3bbab55 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementVerificationMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/RequirementVerificationMembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.Systems.Requirements; using SysML2.NET.Core.POCO.Core.Features; @@ -43,6 +44,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.Constraints; using SysML2.NET.Core.POCO.Systems.Requirements; using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -67,7 +69,8 @@ public class RequirementVerificationMembershipReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public RequirementVerificationMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public RequirementVerificationMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -113,6 +116,8 @@ public override IRequirementVerificationMembership Read(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "RequirementVerificationMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -168,7 +173,7 @@ public override IRequirementVerificationMembership Read(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(kindXmlAttribute)) { - if (Enum.TryParse(kindXmlAttribute, true, out RequirementConstraintKind kindXmlAttributeAsEnum)) + if (RequirementConstraintKindProvider.TryParse(kindXmlAttribute.AsSpan(), out var kindXmlAttributeAsEnum)) { poco.Kind = kindXmlAttributeAsEnum; } @@ -186,6 +191,10 @@ public override IRequirementVerificationMembership Read(XmlReader xmiReader, Uri { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -206,6 +215,10 @@ public override IRequirementVerificationMembership Read(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -222,6 +235,10 @@ public override IRequirementVerificationMembership Read(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -232,13 +249,17 @@ public override IRequirementVerificationMembership Read(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -304,7 +325,14 @@ public override IRequirementVerificationMembership Read(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -316,7 +344,14 @@ public override IRequirementVerificationMembership Read(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -328,7 +363,14 @@ public override IRequirementVerificationMembership Read(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(kindValue)) { - poco.Kind = (RequirementConstraintKind)Enum.Parse(typeof(RequirementConstraintKind), kindValue, true); + if (RequirementConstraintKindProvider.TryParse(kindValue.AsSpan(), out var kindValueAsEnum)) + { + poco.Kind = kindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'kind' on element {ElementId}", kindValue, poco.Id); + } } break; @@ -342,12 +384,18 @@ public override IRequirementVerificationMembership Read(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -363,12 +411,18 @@ public override IRequirementVerificationMembership Read(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -384,12 +438,18 @@ public override IRequirementVerificationMembership Read(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -405,12 +465,18 @@ public override IRequirementVerificationMembership Read(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -424,12 +490,23 @@ public override IRequirementVerificationMembership Read(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading RequirementVerificationMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -479,6 +556,8 @@ public override async Task ReadAsync(XmlRead this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "RequirementVerificationMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -534,7 +613,7 @@ public override async Task ReadAsync(XmlRead if (!string.IsNullOrWhiteSpace(kindXmlAttribute)) { - if (Enum.TryParse(kindXmlAttribute, true, out RequirementConstraintKind kindXmlAttributeAsEnum)) + if (RequirementConstraintKindProvider.TryParse(kindXmlAttribute.AsSpan(), out var kindXmlAttributeAsEnum)) { poco.Kind = kindXmlAttributeAsEnum; } @@ -552,6 +631,10 @@ public override async Task ReadAsync(XmlRead { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -572,6 +655,10 @@ public override async Task ReadAsync(XmlRead { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -588,6 +675,10 @@ public override async Task ReadAsync(XmlRead { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -598,13 +689,17 @@ public override async Task ReadAsync(XmlRead { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -670,7 +765,14 @@ public override async Task ReadAsync(XmlRead if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -682,7 +784,14 @@ public override async Task ReadAsync(XmlRead if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -694,7 +803,14 @@ public override async Task ReadAsync(XmlRead if (!string.IsNullOrWhiteSpace(kindValue)) { - poco.Kind = (RequirementConstraintKind)Enum.Parse(typeof(RequirementConstraintKind), kindValue, true); + if (RequirementConstraintKindProvider.TryParse(kindValue.AsSpan(), out var kindValueAsEnum)) + { + poco.Kind = kindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'kind' on element {ElementId}", kindValue, poco.Id); + } } break; @@ -708,12 +824,18 @@ public override async Task ReadAsync(XmlRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -729,12 +851,18 @@ public override async Task ReadAsync(XmlRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -750,12 +878,18 @@ public override async Task ReadAsync(XmlRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -771,12 +905,18 @@ public override async Task ReadAsync(XmlRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -790,12 +930,23 @@ public override async Task ReadAsync(XmlRead if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading RequirementVerificationMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ResultExpressionMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ResultExpressionMembershipReader.cs index 58df252ca..80d3193cb 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ResultExpressionMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ResultExpressionMembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -40,6 +41,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -64,7 +66,8 @@ public class ResultExpressionMembershipReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public ResultExpressionMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ResultExpressionMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -110,6 +113,8 @@ public override IResultExpressionMembership Read(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ResultExpressionMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -173,6 +178,10 @@ public override IResultExpressionMembership Read(XmlReader xmiReader, Uri curren { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -193,6 +202,10 @@ public override IResultExpressionMembership Read(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -209,6 +222,10 @@ public override IResultExpressionMembership Read(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -219,13 +236,17 @@ public override IResultExpressionMembership Read(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -291,7 +312,14 @@ public override IResultExpressionMembership Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -303,7 +331,14 @@ public override IResultExpressionMembership Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -317,12 +352,18 @@ public override IResultExpressionMembership Read(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -338,12 +379,18 @@ public override IResultExpressionMembership Read(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -359,12 +406,18 @@ public override IResultExpressionMembership Read(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -380,12 +433,18 @@ public override IResultExpressionMembership Read(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -399,12 +458,23 @@ public override IResultExpressionMembership Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ResultExpressionMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -454,6 +524,8 @@ public override async Task ReadAsync(XmlReader xmiR this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ResultExpressionMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -517,6 +589,10 @@ public override async Task ReadAsync(XmlReader xmiR { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -537,6 +613,10 @@ public override async Task ReadAsync(XmlReader xmiR { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -553,6 +633,10 @@ public override async Task ReadAsync(XmlReader xmiR { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -563,13 +647,17 @@ public override async Task ReadAsync(XmlReader xmiR { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -635,7 +723,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -647,7 +742,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -661,12 +763,18 @@ public override async Task ReadAsync(XmlReader xmiR { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -682,12 +790,18 @@ public override async Task ReadAsync(XmlReader xmiR { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -703,12 +817,18 @@ public override async Task ReadAsync(XmlReader xmiR { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -724,12 +844,18 @@ public override async Task ReadAsync(XmlReader xmiR { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -743,12 +869,23 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ResultExpressionMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ReturnParameterMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ReturnParameterMembershipReader.cs index fef0ea8b6..406bb2771 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ReturnParameterMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ReturnParameterMembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -41,6 +42,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -65,7 +67,8 @@ public class ReturnParameterMembershipReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public ReturnParameterMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ReturnParameterMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +114,8 @@ public override IReturnParameterMembership Read(XmlReader xmiReader, Uri current this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ReturnParameterMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -174,6 +179,10 @@ public override IReturnParameterMembership Read(XmlReader xmiReader, Uri current { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -194,6 +203,10 @@ public override IReturnParameterMembership Read(XmlReader xmiReader, Uri current { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -210,6 +223,10 @@ public override IReturnParameterMembership Read(XmlReader xmiReader, Uri current { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -220,13 +237,17 @@ public override IReturnParameterMembership Read(XmlReader xmiReader, Uri current { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -292,7 +313,14 @@ public override IReturnParameterMembership Read(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -304,7 +332,14 @@ public override IReturnParameterMembership Read(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -318,12 +353,18 @@ public override IReturnParameterMembership Read(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -339,12 +380,18 @@ public override IReturnParameterMembership Read(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -360,12 +407,18 @@ public override IReturnParameterMembership Read(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -381,12 +434,18 @@ public override IReturnParameterMembership Read(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -400,12 +459,23 @@ public override IReturnParameterMembership Read(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ReturnParameterMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -455,6 +525,8 @@ public override async Task ReadAsync(XmlReader xmiRe this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ReturnParameterMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -518,6 +590,10 @@ public override async Task ReadAsync(XmlReader xmiRe { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -538,6 +614,10 @@ public override async Task ReadAsync(XmlReader xmiRe { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -554,6 +634,10 @@ public override async Task ReadAsync(XmlReader xmiRe { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -564,13 +648,17 @@ public override async Task ReadAsync(XmlReader xmiRe { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -636,7 +724,14 @@ public override async Task ReadAsync(XmlReader xmiRe if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -648,7 +743,14 @@ public override async Task ReadAsync(XmlReader xmiRe if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -662,12 +764,18 @@ public override async Task ReadAsync(XmlReader xmiRe { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -683,12 +791,18 @@ public override async Task ReadAsync(XmlReader xmiRe { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -704,12 +818,18 @@ public override async Task ReadAsync(XmlReader xmiRe { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -725,12 +845,18 @@ public override async Task ReadAsync(XmlReader xmiRe { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -744,12 +870,23 @@ public override async Task ReadAsync(XmlReader xmiRe if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ReturnParameterMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SatisfyRequirementUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SatisfyRequirementUsageReader.cs index ccfc054bf..67bd016a4 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SatisfyRequirementUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SatisfyRequirementUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class SatisfyRequirementUsageReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public SatisfyRequirementUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public SatisfyRequirementUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SatisfyRequirementUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -157,7 +162,7 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -312,6 +317,10 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -328,13 +337,17 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -383,7 +396,14 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -407,7 +427,14 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -419,7 +446,14 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -431,7 +465,14 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -443,7 +484,14 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -455,7 +503,14 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -467,7 +522,14 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -479,7 +541,14 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -491,7 +560,14 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isNegatedValue)) { - poco.IsNegated = bool.Parse(isNegatedValue); + if (bool.TryParse(isNegatedValue, out var isNegatedValueAsBool)) + { + poco.IsNegated = isNegatedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isNegated' on element {ElementId}", isNegatedValue, poco.Id); + } } break; @@ -503,7 +579,14 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -515,7 +598,14 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -527,7 +617,14 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -539,7 +636,14 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -551,7 +655,14 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -565,12 +676,18 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -586,12 +703,18 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -605,7 +728,14 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; @@ -623,6 +753,10 @@ public override ISatisfyRequirementUsage Read(XmlReader xmiReader, Uri currentLo break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SatisfyRequirementUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -672,6 +806,8 @@ public override async Task ReadAsync(XmlReader xmiRead this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SatisfyRequirementUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -693,7 +829,7 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -848,6 +984,10 @@ public override async Task ReadAsync(XmlReader xmiRead { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -864,13 +1004,17 @@ public override async Task ReadAsync(XmlReader xmiRead { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -919,7 +1063,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -943,7 +1094,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -955,7 +1113,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -967,7 +1132,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -979,7 +1151,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -991,7 +1170,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1003,7 +1189,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1015,7 +1208,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1027,7 +1227,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isNegatedValue)) { - poco.IsNegated = bool.Parse(isNegatedValue); + if (bool.TryParse(isNegatedValue, out var isNegatedValueAsBool)) + { + poco.IsNegated = isNegatedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isNegated' on element {ElementId}", isNegatedValue, poco.Id); + } } break; @@ -1039,7 +1246,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1051,7 +1265,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1063,7 +1284,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1075,7 +1303,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1087,7 +1322,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1101,12 +1343,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1122,12 +1370,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1141,7 +1395,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; @@ -1159,6 +1420,10 @@ public override async Task ReadAsync(XmlReader xmiRead break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SatisfyRequirementUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SelectExpressionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SelectExpressionReader.cs index b8859ceea..5368ea304 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SelectExpressionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SelectExpressionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class SelectExpressionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public SelectExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public SelectExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SelectExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -140,7 +145,7 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -282,6 +287,10 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -298,6 +307,10 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -348,7 +361,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -372,7 +392,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -384,7 +411,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -396,7 +430,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -408,7 +449,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -420,7 +468,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -432,7 +487,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -444,7 +506,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -456,7 +525,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -468,7 +544,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -480,7 +563,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -492,7 +582,14 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -518,12 +615,18 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -539,12 +642,18 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -552,6 +661,10 @@ public override ISelectExpression Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SelectExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -601,6 +714,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SelectExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -629,7 +744,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -771,6 +886,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -787,6 +906,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -837,7 +960,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -861,7 +991,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -873,7 +1010,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -885,7 +1029,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -897,7 +1048,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -909,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -921,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -933,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -945,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -957,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -969,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -981,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1007,12 +1214,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1028,12 +1241,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1041,6 +1260,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SelectExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SendActionUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SendActionUsageReader.cs index 2abb0b9a2..756737ad0 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SendActionUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SendActionUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class SendActionUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public SendActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public SendActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SendActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override ISendActionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SendActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SendActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SendActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SpecializationReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SpecializationReader.cs index 174b5f84b..eb6c89273 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SpecializationReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SpecializationReader.cs @@ -33,10 +33,12 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -61,7 +63,8 @@ public class SpecializationReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public SpecializationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public SpecializationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -107,6 +110,8 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Specialization", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -146,6 +151,10 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "general", generalXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'general' on element {ElementId}", generalXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -180,6 +189,10 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -200,6 +213,10 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -216,6 +233,10 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -226,6 +247,10 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var specificXmlAttribute = xmiReader.GetAttribute("specific"); @@ -236,6 +261,10 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "specific", specificXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'specific' on element {ElementId}", specificXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -300,12 +329,18 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var generalId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "general", generalId); + if (Guid.TryParse(hrefSplit[1], out var generalId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "general", generalId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'general' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var generalValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var generalValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.General = generalValue; } @@ -319,7 +354,14 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -331,7 +373,14 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -345,12 +394,18 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -366,12 +421,18 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -387,12 +448,18 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -408,12 +475,18 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -429,12 +502,18 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var specificId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "specific", specificId); + if (Guid.TryParse(hrefSplit[1], out var specificId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "specific", specificId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'specific' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var specificValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var specificValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Specific = specificValue; } @@ -442,6 +521,10 @@ public override ISpecialization Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Specialization at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -491,6 +574,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Specialization", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -530,6 +615,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "general", generalXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'general' on element {ElementId}", generalXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -564,6 +653,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -584,6 +677,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -600,6 +697,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -610,6 +711,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var specificXmlAttribute = xmiReader.GetAttribute("specific"); @@ -620,6 +725,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "specific", specificXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'specific' on element {ElementId}", specificXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -684,12 +793,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var generalId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "general", generalId); + if (Guid.TryParse(hrefSplit[1], out var generalId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "general", generalId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'general' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var generalValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var generalValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.General = generalValue; } @@ -703,7 +818,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -715,7 +837,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -729,12 +858,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -750,12 +885,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -771,12 +912,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -792,12 +939,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -813,12 +966,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var specificId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "specific", specificId); + if (Guid.TryParse(hrefSplit[1], out var specificId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "specific", specificId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'specific' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var specificValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var specificValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Specific = specificValue; } @@ -826,6 +985,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Specialization at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StakeholderMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StakeholderMembershipReader.cs index 4d02154db..37b96d7c0 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StakeholderMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StakeholderMembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.Parts; using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class StakeholderMembershipReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public StakeholderMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public StakeholderMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override IStakeholderMembership Read(XmlReader xmiReader, Uri currentLoca this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "StakeholderMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -175,6 +180,10 @@ public override IStakeholderMembership Read(XmlReader xmiReader, Uri currentLoca { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -195,6 +204,10 @@ public override IStakeholderMembership Read(XmlReader xmiReader, Uri currentLoca { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -211,6 +224,10 @@ public override IStakeholderMembership Read(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -221,13 +238,17 @@ public override IStakeholderMembership Read(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -293,7 +314,14 @@ public override IStakeholderMembership Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -305,7 +333,14 @@ public override IStakeholderMembership Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -319,12 +354,18 @@ public override IStakeholderMembership Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -340,12 +381,18 @@ public override IStakeholderMembership Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -361,12 +408,18 @@ public override IStakeholderMembership Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -382,12 +435,18 @@ public override IStakeholderMembership Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -401,12 +460,23 @@ public override IStakeholderMembership Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading StakeholderMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -456,6 +526,8 @@ public override async Task ReadAsync(XmlReader xmiReader this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "StakeholderMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -519,6 +591,10 @@ public override async Task ReadAsync(XmlReader xmiReader { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -539,6 +615,10 @@ public override async Task ReadAsync(XmlReader xmiReader { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -555,6 +635,10 @@ public override async Task ReadAsync(XmlReader xmiReader { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -565,13 +649,17 @@ public override async Task ReadAsync(XmlReader xmiReader { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -637,7 +725,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -649,7 +744,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -663,12 +765,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -684,12 +792,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -705,12 +819,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -726,12 +846,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -745,12 +871,23 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading StakeholderMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StateDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StateDefinitionReader.cs index a225dd9a3..6032af5c7 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StateDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StateDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -62,6 +63,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -86,7 +88,8 @@ public class StateDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public StateDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public StateDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -132,6 +135,8 @@ public override IStateDefinition Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "StateDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -235,6 +240,10 @@ public override IStateDefinition Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -251,6 +260,10 @@ public override IStateDefinition Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -313,7 +326,14 @@ public override IStateDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -325,7 +345,14 @@ public override IStateDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -337,7 +364,14 @@ public override IStateDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -349,7 +383,14 @@ public override IStateDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isParallelValue)) { - poco.IsParallel = bool.Parse(isParallelValue); + if (bool.TryParse(isParallelValue, out var isParallelValueAsBool)) + { + poco.IsParallel = isParallelValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isParallel' on element {ElementId}", isParallelValue, poco.Id); + } } break; @@ -361,7 +402,14 @@ public override IStateDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -373,7 +421,14 @@ public override IStateDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -387,12 +442,18 @@ public override IStateDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -408,12 +469,18 @@ public override IStateDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -421,6 +488,10 @@ public override IStateDefinition Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading StateDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -470,6 +541,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "StateDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -573,6 +646,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -589,6 +666,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -651,7 +732,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -663,7 +751,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -675,7 +770,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -687,7 +789,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isParallelValue)) { - poco.IsParallel = bool.Parse(isParallelValue); + if (bool.TryParse(isParallelValue, out var isParallelValueAsBool)) + { + poco.IsParallel = isParallelValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isParallel' on element {ElementId}", isParallelValue, poco.Id); + } } break; @@ -699,7 +808,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -711,7 +827,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -725,12 +848,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -746,12 +875,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -759,6 +894,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading StateDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StateSubactionMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StateSubactionMembershipReader.cs index 32412b6ce..434e6de8b 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StateSubactionMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StateSubactionMembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.Systems.States; using SysML2.NET.Core.POCO.Core.Features; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.Actions; using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class StateSubactionMembershipReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public StateSubactionMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public StateSubactionMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override IStateSubactionMembership Read(XmlReader xmiReader, Uri currentL this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "StateSubactionMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -167,7 +172,7 @@ public override IStateSubactionMembership Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(kindXmlAttribute)) { - if (Enum.TryParse(kindXmlAttribute, true, out StateSubactionKind kindXmlAttributeAsEnum)) + if (StateSubactionKindProvider.TryParse(kindXmlAttribute.AsSpan(), out var kindXmlAttributeAsEnum)) { poco.Kind = kindXmlAttributeAsEnum; } @@ -185,6 +190,10 @@ public override IStateSubactionMembership Read(XmlReader xmiReader, Uri currentL { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -205,6 +214,10 @@ public override IStateSubactionMembership Read(XmlReader xmiReader, Uri currentL { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -221,6 +234,10 @@ public override IStateSubactionMembership Read(XmlReader xmiReader, Uri currentL { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -231,13 +248,17 @@ public override IStateSubactionMembership Read(XmlReader xmiReader, Uri currentL { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -303,7 +324,14 @@ public override IStateSubactionMembership Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -315,7 +343,14 @@ public override IStateSubactionMembership Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -327,7 +362,14 @@ public override IStateSubactionMembership Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(kindValue)) { - poco.Kind = (StateSubactionKind)Enum.Parse(typeof(StateSubactionKind), kindValue, true); + if (StateSubactionKindProvider.TryParse(kindValue.AsSpan(), out var kindValueAsEnum)) + { + poco.Kind = kindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'kind' on element {ElementId}", kindValue, poco.Id); + } } break; @@ -341,12 +383,18 @@ public override IStateSubactionMembership Read(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -362,12 +410,18 @@ public override IStateSubactionMembership Read(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -383,12 +437,18 @@ public override IStateSubactionMembership Read(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -404,12 +464,18 @@ public override IStateSubactionMembership Read(XmlReader xmiReader, Uri currentL { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -423,12 +489,23 @@ public override IStateSubactionMembership Read(XmlReader xmiReader, Uri currentL if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading StateSubactionMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -478,6 +555,8 @@ public override async Task ReadAsync(XmlReader xmiRea this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "StateSubactionMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -533,7 +612,7 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(kindXmlAttribute)) { - if (Enum.TryParse(kindXmlAttribute, true, out StateSubactionKind kindXmlAttributeAsEnum)) + if (StateSubactionKindProvider.TryParse(kindXmlAttribute.AsSpan(), out var kindXmlAttributeAsEnum)) { poco.Kind = kindXmlAttributeAsEnum; } @@ -551,6 +630,10 @@ public override async Task ReadAsync(XmlReader xmiRea { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -571,6 +654,10 @@ public override async Task ReadAsync(XmlReader xmiRea { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -587,6 +674,10 @@ public override async Task ReadAsync(XmlReader xmiRea { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -597,13 +688,17 @@ public override async Task ReadAsync(XmlReader xmiRea { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -669,7 +764,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -681,7 +783,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -693,7 +802,14 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(kindValue)) { - poco.Kind = (StateSubactionKind)Enum.Parse(typeof(StateSubactionKind), kindValue, true); + if (StateSubactionKindProvider.TryParse(kindValue.AsSpan(), out var kindValueAsEnum)) + { + poco.Kind = kindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'kind' on element {ElementId}", kindValue, poco.Id); + } } break; @@ -707,12 +823,18 @@ public override async Task ReadAsync(XmlReader xmiRea { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -728,12 +850,18 @@ public override async Task ReadAsync(XmlReader xmiRea { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -749,12 +877,18 @@ public override async Task ReadAsync(XmlReader xmiRea { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -770,12 +904,18 @@ public override async Task ReadAsync(XmlReader xmiRea { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -789,12 +929,23 @@ public override async Task ReadAsync(XmlReader xmiRea if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading StateSubactionMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StateUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StateUsageReader.cs index 97c2fdddf..dfd2c8e5d 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StateUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StateUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -65,6 +66,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -89,7 +91,8 @@ public class StateUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public StateUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public StateUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -135,6 +138,8 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "StateUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -163,7 +168,7 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -318,6 +323,10 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -334,13 +343,17 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -394,7 +407,14 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -418,7 +438,14 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -430,7 +457,14 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -442,7 +476,14 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -454,7 +495,14 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -466,7 +514,14 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -478,7 +533,14 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -490,7 +552,14 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -502,7 +571,14 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -514,7 +590,14 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isParallelValue)) { - poco.IsParallel = bool.Parse(isParallelValue); + if (bool.TryParse(isParallelValue, out var isParallelValueAsBool)) + { + poco.IsParallel = isParallelValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isParallel' on element {ElementId}", isParallelValue, poco.Id); + } } break; @@ -526,7 +609,14 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -538,7 +628,14 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -550,7 +647,14 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -562,7 +666,14 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -576,12 +687,18 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -597,12 +714,18 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -616,12 +739,23 @@ public override IStateUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading StateUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -671,6 +805,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "StateUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -699,7 +835,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -854,6 +990,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -870,13 +1010,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -930,7 +1074,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -954,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -966,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -978,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -990,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1002,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1014,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1026,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1038,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1050,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isParallelValue)) { - poco.IsParallel = bool.Parse(isParallelValue); + if (bool.TryParse(isParallelValue, out var isParallelValueAsBool)) + { + poco.IsParallel = isParallelValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isParallel' on element {ElementId}", isParallelValue, poco.Id); + } } break; @@ -1062,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1074,7 +1295,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1086,7 +1314,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1098,7 +1333,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1112,12 +1354,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1133,12 +1381,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1152,12 +1406,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading StateUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StepReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StepReader.cs index dc74613c9..4d02effb6 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StepReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StepReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -40,6 +41,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -64,7 +66,8 @@ public class StepReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public StepReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public StepReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -110,6 +113,8 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Step", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -138,7 +143,7 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -273,6 +278,10 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -289,6 +298,10 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -339,7 +352,14 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -363,7 +383,14 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -375,7 +402,14 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -387,7 +421,14 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -399,7 +440,14 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -411,7 +459,14 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -423,7 +478,14 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -435,7 +497,14 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -447,7 +516,14 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -459,7 +535,14 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -471,7 +554,14 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -483,7 +573,14 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -497,12 +594,18 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -518,12 +621,18 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -531,6 +640,10 @@ public override IStep Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Step at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -580,6 +693,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Step", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -608,7 +723,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -743,6 +858,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -759,6 +878,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -809,7 +932,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -833,7 +963,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -845,7 +982,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -857,7 +1001,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -869,7 +1020,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -881,7 +1039,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -893,7 +1058,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -905,7 +1077,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -917,7 +1096,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -929,7 +1115,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -941,7 +1134,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -953,7 +1153,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -967,12 +1174,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -988,12 +1201,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1001,6 +1220,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Step at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StructureReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StructureReader.cs index fd2bf85e6..cdc2ec746 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StructureReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/StructureReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -41,6 +42,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Structures; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -65,7 +67,8 @@ public class StructureReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public StructureReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public StructureReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +114,8 @@ public override IStructure Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Structure", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -184,6 +189,10 @@ public override IStructure Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -200,6 +209,10 @@ public override IStructure Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -262,7 +275,14 @@ public override IStructure Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -274,7 +294,14 @@ public override IStructure Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -286,7 +313,14 @@ public override IStructure Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -300,12 +334,18 @@ public override IStructure Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -321,12 +361,18 @@ public override IStructure Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -334,6 +380,10 @@ public override IStructure Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Structure at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -383,6 +433,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Structure", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -456,6 +508,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -472,6 +528,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -534,7 +594,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -546,7 +613,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -558,7 +632,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -572,12 +653,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -593,12 +680,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -606,6 +699,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Structure at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SubclassificationReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SubclassificationReader.cs index 5b4418ba0..441c66d7b 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SubclassificationReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SubclassificationReader.cs @@ -33,11 +33,13 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -62,7 +64,8 @@ public class SubclassificationReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public SubclassificationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public SubclassificationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +111,8 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Subclassification", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -171,6 +176,10 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -191,6 +200,10 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -207,6 +220,10 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -217,6 +234,10 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var subclassifierXmlAttribute = xmiReader.GetAttribute("subclassifier"); @@ -227,6 +248,10 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subclassifier", subclassifierXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'subclassifier' on element {ElementId}", subclassifierXmlAttribute, poco.Id); + } } var superclassifierXmlAttribute = xmiReader.GetAttribute("superclassifier"); @@ -237,6 +262,10 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "superclassifier", superclassifierXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'superclassifier' on element {ElementId}", superclassifierXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -299,7 +328,14 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -311,7 +347,14 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -325,12 +368,18 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -346,12 +395,18 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -367,12 +422,18 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -388,12 +449,18 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -409,12 +476,18 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var subclassifierId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subclassifier", subclassifierId); + if (Guid.TryParse(hrefSplit[1], out var subclassifierId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subclassifier", subclassifierId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'subclassifier' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var subclassifierValue = (IClassifier)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var subclassifierValue = (IClassifier)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Subclassifier = subclassifierValue; } @@ -430,12 +503,18 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var superclassifierId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "superclassifier", superclassifierId); + if (Guid.TryParse(hrefSplit[1], out var superclassifierId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "superclassifier", superclassifierId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'superclassifier' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var superclassifierValue = (IClassifier)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var superclassifierValue = (IClassifier)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Superclassifier = superclassifierValue; } @@ -443,6 +522,10 @@ public override ISubclassification Read(XmlReader xmiReader, Uri currentLocation break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Subclassification at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -492,6 +575,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Subclassification", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -555,6 +640,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -575,6 +664,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -591,6 +684,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -601,6 +698,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var subclassifierXmlAttribute = xmiReader.GetAttribute("subclassifier"); @@ -611,6 +712,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subclassifier", subclassifierXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'subclassifier' on element {ElementId}", subclassifierXmlAttribute, poco.Id); + } } var superclassifierXmlAttribute = xmiReader.GetAttribute("superclassifier"); @@ -621,6 +726,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "superclassifier", superclassifierXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'superclassifier' on element {ElementId}", superclassifierXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -683,7 +792,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -695,7 +811,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -709,12 +832,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -730,12 +859,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -751,12 +886,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -772,12 +913,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -793,12 +940,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var subclassifierId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subclassifier", subclassifierId); + if (Guid.TryParse(hrefSplit[1], out var subclassifierId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subclassifier", subclassifierId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'subclassifier' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var subclassifierValue = (IClassifier)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var subclassifierValue = (IClassifier)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Subclassifier = subclassifierValue; } @@ -814,12 +967,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var superclassifierId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "superclassifier", superclassifierId); + if (Guid.TryParse(hrefSplit[1], out var superclassifierId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "superclassifier", superclassifierId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'superclassifier' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var superclassifierValue = (IClassifier)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var superclassifierValue = (IClassifier)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.Superclassifier = superclassifierValue; } @@ -827,6 +986,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Subclassification at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SubjectMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SubjectMembershipReader.cs index 18008a8af..fb6af79c2 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SubjectMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SubjectMembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class SubjectMembershipReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public SubjectMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public SubjectMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override ISubjectMembership Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SubjectMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -175,6 +180,10 @@ public override ISubjectMembership Read(XmlReader xmiReader, Uri currentLocation { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -195,6 +204,10 @@ public override ISubjectMembership Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -211,6 +224,10 @@ public override ISubjectMembership Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -221,13 +238,17 @@ public override ISubjectMembership Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -293,7 +314,14 @@ public override ISubjectMembership Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -305,7 +333,14 @@ public override ISubjectMembership Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -319,12 +354,18 @@ public override ISubjectMembership Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -340,12 +381,18 @@ public override ISubjectMembership Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -361,12 +408,18 @@ public override ISubjectMembership Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -382,12 +435,18 @@ public override ISubjectMembership Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -401,12 +460,23 @@ public override ISubjectMembership Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SubjectMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -456,6 +526,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SubjectMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -519,6 +591,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -539,6 +615,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -555,6 +635,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -565,13 +649,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -637,7 +725,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -649,7 +744,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -663,12 +765,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -684,12 +792,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -705,12 +819,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -726,12 +846,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -745,12 +871,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SubjectMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SubsettingReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SubsettingReader.cs index e792edb14..d88f9ed4e 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SubsettingReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SubsettingReader.cs @@ -33,11 +33,13 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -62,7 +64,8 @@ public class SubsettingReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public SubsettingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public SubsettingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +111,8 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Subsetting", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -171,6 +176,10 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -191,6 +200,10 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -207,6 +220,10 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -217,6 +234,10 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var subsettedFeatureXmlAttribute = xmiReader.GetAttribute("subsettedFeature"); @@ -227,6 +248,10 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subsettedFeature", subsettedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'subsettedFeature' on element {ElementId}", subsettedFeatureXmlAttribute, poco.Id); + } } var subsettingFeatureXmlAttribute = xmiReader.GetAttribute("subsettingFeature"); @@ -237,6 +262,10 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subsettingFeature", subsettingFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'subsettingFeature' on element {ElementId}", subsettingFeatureXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -299,7 +328,14 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -311,7 +347,14 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -325,12 +368,18 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -346,12 +395,18 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -367,12 +422,18 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -388,12 +449,18 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -409,12 +476,18 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var subsettedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subsettedFeature", subsettedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var subsettedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subsettedFeature", subsettedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'subsettedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var subsettedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var subsettedFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.SubsettedFeature = subsettedFeatureValue; } @@ -430,12 +503,18 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var subsettingFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subsettingFeature", subsettingFeatureId); + if (Guid.TryParse(hrefSplit[1], out var subsettingFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subsettingFeature", subsettingFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'subsettingFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var subsettingFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var subsettingFeatureValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.SubsettingFeature = subsettingFeatureValue; } @@ -443,6 +522,10 @@ public override ISubsetting Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Subsetting at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -492,6 +575,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Subsetting", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -555,6 +640,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -575,6 +664,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -591,6 +684,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -601,6 +698,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var subsettedFeatureXmlAttribute = xmiReader.GetAttribute("subsettedFeature"); @@ -611,6 +712,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subsettedFeature", subsettedFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'subsettedFeature' on element {ElementId}", subsettedFeatureXmlAttribute, poco.Id); + } } var subsettingFeatureXmlAttribute = xmiReader.GetAttribute("subsettingFeature"); @@ -621,6 +726,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subsettingFeature", subsettingFeatureXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'subsettingFeature' on element {ElementId}", subsettingFeatureXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -683,7 +792,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -695,7 +811,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -709,12 +832,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -730,12 +859,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -751,12 +886,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -772,12 +913,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -793,12 +940,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var subsettedFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subsettedFeature", subsettedFeatureId); + if (Guid.TryParse(hrefSplit[1], out var subsettedFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subsettedFeature", subsettedFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'subsettedFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var subsettedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var subsettedFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.SubsettedFeature = subsettedFeatureValue; } @@ -814,12 +967,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var subsettingFeatureId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subsettingFeature", subsettingFeatureId); + if (Guid.TryParse(hrefSplit[1], out var subsettingFeatureId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "subsettingFeature", subsettingFeatureId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'subsettingFeature' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var subsettingFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var subsettingFeatureValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.SubsettingFeature = subsettingFeatureValue; } @@ -827,6 +986,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Subsetting at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionAsUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionAsUsageReader.cs index 5cba6cda6..fe02f36d6 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionAsUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionAsUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; @@ -64,6 +65,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -88,7 +90,8 @@ public class SuccessionAsUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public SuccessionAsUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public SuccessionAsUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -134,6 +137,8 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SuccessionAsUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -162,7 +167,7 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -307,6 +312,10 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -327,6 +336,10 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -343,6 +356,10 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -353,6 +370,10 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -403,7 +424,14 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -427,7 +455,14 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -439,7 +474,14 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -451,7 +493,14 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -463,7 +512,14 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -475,7 +531,14 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -487,7 +550,14 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -499,7 +569,14 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -511,7 +588,14 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -523,7 +607,14 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -535,7 +626,14 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -547,7 +645,14 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -559,7 +664,14 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -573,12 +685,18 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -594,12 +712,18 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -615,12 +739,18 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -636,12 +766,18 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -649,6 +785,10 @@ public override ISuccessionAsUsage Read(XmlReader xmiReader, Uri currentLocation break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SuccessionAsUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -698,6 +838,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SuccessionAsUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -726,7 +868,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -871,6 +1013,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -891,6 +1037,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -907,6 +1057,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -917,6 +1071,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -967,7 +1125,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -991,7 +1156,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -1003,7 +1175,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -1015,7 +1194,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -1027,7 +1213,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1039,7 +1232,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1051,7 +1251,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -1063,7 +1270,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1075,7 +1289,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1087,7 +1308,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1099,7 +1327,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1111,7 +1346,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1123,7 +1365,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1137,12 +1386,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -1158,12 +1413,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1179,12 +1440,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -1200,12 +1467,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1213,6 +1486,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SuccessionAsUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionFlowReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionFlowReader.cs index 2bec6f31e..1eaf380c1 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionFlowReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionFlowReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; @@ -44,6 +45,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Interactions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -68,7 +70,8 @@ public class SuccessionFlowReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public SuccessionFlowReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public SuccessionFlowReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -114,6 +117,8 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SuccessionFlow", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -142,7 +147,7 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -287,6 +292,10 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -307,6 +316,10 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -323,6 +336,10 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -333,6 +350,10 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -383,7 +404,14 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -407,7 +435,14 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -419,7 +454,14 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -431,7 +473,14 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -443,7 +492,14 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -455,7 +511,14 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -467,7 +530,14 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -479,7 +549,14 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -491,7 +568,14 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -503,7 +587,14 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -515,7 +606,14 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -527,7 +625,14 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -539,7 +644,14 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -553,12 +665,18 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -574,12 +692,18 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -595,12 +719,18 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -616,12 +746,18 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -629,6 +765,10 @@ public override ISuccessionFlow Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SuccessionFlow at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -678,6 +818,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SuccessionFlow", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -706,7 +848,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -851,6 +993,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -871,6 +1017,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -887,6 +1037,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -897,6 +1051,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -971,7 +1136,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -983,7 +1155,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -995,7 +1174,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -1007,7 +1193,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1019,7 +1212,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1031,7 +1231,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -1043,7 +1250,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1055,7 +1269,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1067,7 +1288,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1079,7 +1307,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1091,7 +1326,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1103,7 +1345,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1117,12 +1366,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -1138,12 +1393,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1159,12 +1420,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -1180,12 +1447,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1193,6 +1466,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SuccessionFlow at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionFlowUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionFlowUsageReader.cs index e6afa8660..6814fc8eb 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionFlowUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionFlowUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -68,6 +69,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -92,7 +94,8 @@ public class SuccessionFlowUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public SuccessionFlowUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public SuccessionFlowUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -138,6 +141,8 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SuccessionFlowUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -166,7 +171,7 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -321,6 +326,10 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -341,6 +350,10 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -357,6 +370,10 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -367,13 +384,17 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -427,7 +448,14 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -451,7 +479,14 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -463,7 +498,14 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -475,7 +517,14 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -487,7 +536,14 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -499,7 +555,14 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -511,7 +574,14 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -523,7 +593,14 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -535,7 +612,14 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -547,7 +631,14 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -559,7 +650,14 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -571,7 +669,14 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -583,7 +688,14 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -595,7 +707,14 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -609,12 +728,18 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -630,12 +755,18 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -651,12 +782,18 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -672,12 +809,18 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -691,12 +834,23 @@ public override ISuccessionFlowUsage Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SuccessionFlowUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -746,6 +900,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "SuccessionFlowUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -774,7 +930,7 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -929,6 +1085,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -949,6 +1109,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -965,6 +1129,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -975,13 +1143,17 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -1035,7 +1207,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -1059,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -1071,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -1083,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -1095,7 +1295,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1107,7 +1314,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1119,7 +1333,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -1131,7 +1352,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1143,7 +1371,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1155,7 +1390,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1167,7 +1409,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1179,7 +1428,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1191,7 +1447,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1203,7 +1466,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1217,12 +1487,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -1238,12 +1514,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1259,12 +1541,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -1280,12 +1568,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1299,12 +1593,23 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading SuccessionFlowUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionReader.cs index 1e55cf9e8..e46703d1b 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/SuccessionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -41,6 +42,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -65,7 +67,8 @@ public class SuccessionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public SuccessionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public SuccessionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -111,6 +114,8 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Succession", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -139,7 +144,7 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -284,6 +289,10 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -304,6 +313,10 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -320,6 +333,10 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -330,6 +347,10 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -380,7 +401,14 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -404,7 +432,14 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -416,7 +451,14 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -428,7 +470,14 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -440,7 +489,14 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -452,7 +508,14 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -464,7 +527,14 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -476,7 +546,14 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -488,7 +565,14 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -500,7 +584,14 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -512,7 +603,14 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -524,7 +622,14 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -536,7 +641,14 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -550,12 +662,18 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -571,12 +689,18 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -592,12 +716,18 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -613,12 +743,18 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -626,6 +762,10 @@ public override ISuccession Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Succession at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -675,6 +815,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Succession", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -703,7 +845,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -848,6 +990,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -868,6 +1014,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -884,6 +1034,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -894,6 +1048,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -944,7 +1102,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -968,7 +1133,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -980,7 +1152,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -992,7 +1171,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -1004,7 +1190,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -1016,7 +1209,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -1028,7 +1228,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -1040,7 +1247,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -1052,7 +1266,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1064,7 +1285,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1076,7 +1304,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1088,7 +1323,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1100,7 +1342,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1114,12 +1363,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -1135,12 +1390,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1156,12 +1417,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -1177,12 +1444,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1190,6 +1463,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curre break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Succession at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TerminateActionUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TerminateActionUsageReader.cs index bcd5f20d6..ebb65b293 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TerminateActionUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TerminateActionUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class TerminateActionUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public TerminateActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public TerminateActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "TerminateActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override ITerminateActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading TerminateActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "TerminateActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading TerminateActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TextualRepresentationReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TextualRepresentationReader.cs index 6916876ad..7e84e4777 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TextualRepresentationReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TextualRepresentationReader.cs @@ -33,9 +33,11 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -60,7 +62,8 @@ public class TextualRepresentationReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public TextualRepresentationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public TextualRepresentationReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -106,6 +109,8 @@ public override ITextualRepresentation Read(XmlReader xmiReader, Uri currentLoca this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "TextualRepresentation", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -173,6 +178,10 @@ public override ITextualRepresentation Read(XmlReader xmiReader, Uri currentLoca { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -189,6 +198,10 @@ public override ITextualRepresentation Read(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -263,7 +276,14 @@ public override ITextualRepresentation Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -289,12 +309,18 @@ public override ITextualRepresentation Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -310,12 +336,18 @@ public override ITextualRepresentation Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -323,6 +355,10 @@ public override ITextualRepresentation Read(XmlReader xmiReader, Uri currentLoca break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading TextualRepresentation at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -372,6 +408,8 @@ public override async Task ReadAsync(XmlReader xmiReader this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "TextualRepresentation", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -439,6 +477,10 @@ public override async Task ReadAsync(XmlReader xmiReader { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -455,6 +497,10 @@ public override async Task ReadAsync(XmlReader xmiReader { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -529,7 +575,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -555,12 +608,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +635,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -589,6 +654,10 @@ public override async Task ReadAsync(XmlReader xmiReader break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading TextualRepresentation at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TransitionFeatureMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TransitionFeatureMembershipReader.cs index 56496b3f9..69968df2a 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TransitionFeatureMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TransitionFeatureMembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.Systems.States; using SysML2.NET.Core.POCO.Core.Features; @@ -42,6 +43,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -66,7 +68,8 @@ public class TransitionFeatureMembershipReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public TransitionFeatureMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public TransitionFeatureMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -112,6 +115,8 @@ public override ITransitionFeatureMembership Read(XmlReader xmiReader, Uri curre this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "TransitionFeatureMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -167,7 +172,7 @@ public override ITransitionFeatureMembership Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(kindXmlAttribute)) { - if (Enum.TryParse(kindXmlAttribute, true, out TransitionFeatureKind kindXmlAttributeAsEnum)) + if (TransitionFeatureKindProvider.TryParse(kindXmlAttribute.AsSpan(), out var kindXmlAttributeAsEnum)) { poco.Kind = kindXmlAttributeAsEnum; } @@ -185,6 +190,10 @@ public override ITransitionFeatureMembership Read(XmlReader xmiReader, Uri curre { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -205,6 +214,10 @@ public override ITransitionFeatureMembership Read(XmlReader xmiReader, Uri curre { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -221,6 +234,10 @@ public override ITransitionFeatureMembership Read(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -231,13 +248,17 @@ public override ITransitionFeatureMembership Read(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -303,7 +324,14 @@ public override ITransitionFeatureMembership Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -315,7 +343,14 @@ public override ITransitionFeatureMembership Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -327,7 +362,14 @@ public override ITransitionFeatureMembership Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(kindValue)) { - poco.Kind = (TransitionFeatureKind)Enum.Parse(typeof(TransitionFeatureKind), kindValue, true); + if (TransitionFeatureKindProvider.TryParse(kindValue.AsSpan(), out var kindValueAsEnum)) + { + poco.Kind = kindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'kind' on element {ElementId}", kindValue, poco.Id); + } } break; @@ -341,12 +383,18 @@ public override ITransitionFeatureMembership Read(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -362,12 +410,18 @@ public override ITransitionFeatureMembership Read(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -383,12 +437,18 @@ public override ITransitionFeatureMembership Read(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -404,12 +464,18 @@ public override ITransitionFeatureMembership Read(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -423,12 +489,23 @@ public override ITransitionFeatureMembership Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading TransitionFeatureMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -478,6 +555,8 @@ public override async Task ReadAsync(XmlReader xmi this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "TransitionFeatureMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -533,7 +612,7 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(kindXmlAttribute)) { - if (Enum.TryParse(kindXmlAttribute, true, out TransitionFeatureKind kindXmlAttributeAsEnum)) + if (TransitionFeatureKindProvider.TryParse(kindXmlAttribute.AsSpan(), out var kindXmlAttributeAsEnum)) { poco.Kind = kindXmlAttributeAsEnum; } @@ -551,6 +630,10 @@ public override async Task ReadAsync(XmlReader xmi { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -571,6 +654,10 @@ public override async Task ReadAsync(XmlReader xmi { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -587,6 +674,10 @@ public override async Task ReadAsync(XmlReader xmi { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -597,13 +688,17 @@ public override async Task ReadAsync(XmlReader xmi { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -669,7 +764,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -681,7 +783,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -693,7 +802,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(kindValue)) { - poco.Kind = (TransitionFeatureKind)Enum.Parse(typeof(TransitionFeatureKind), kindValue, true); + if (TransitionFeatureKindProvider.TryParse(kindValue.AsSpan(), out var kindValueAsEnum)) + { + poco.Kind = kindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'kind' on element {ElementId}", kindValue, poco.Id); + } } break; @@ -707,12 +823,18 @@ public override async Task ReadAsync(XmlReader xmi { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -728,12 +850,18 @@ public override async Task ReadAsync(XmlReader xmi { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -749,12 +877,18 @@ public override async Task ReadAsync(XmlReader xmi { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -770,12 +904,18 @@ public override async Task ReadAsync(XmlReader xmi { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -789,12 +929,23 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading TransitionFeatureMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TransitionUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TransitionUsageReader.cs index 1ae1e0dcb..8cc9f924a 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TransitionUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TransitionUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -67,6 +68,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -91,7 +93,8 @@ public class TransitionUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public TransitionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public TransitionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -137,6 +140,8 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "TransitionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -165,7 +170,7 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -310,6 +315,10 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -326,13 +335,17 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -386,7 +399,14 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -410,7 +430,14 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -422,7 +449,14 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -434,7 +468,14 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -446,7 +487,14 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -458,7 +506,14 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -470,7 +525,14 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -482,7 +544,14 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -494,7 +563,14 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -506,7 +582,14 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -518,7 +601,14 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -530,7 +620,14 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -542,7 +639,14 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -556,12 +660,18 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -577,12 +687,18 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -596,12 +712,23 @@ public override ITransitionUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading TransitionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -651,6 +778,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "TransitionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -679,7 +808,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -824,6 +953,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -840,13 +973,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -900,7 +1037,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -924,7 +1068,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -936,7 +1087,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -948,7 +1106,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -960,7 +1125,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -972,7 +1144,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -984,7 +1163,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -996,7 +1182,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1008,7 +1201,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1020,7 +1220,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1032,7 +1239,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1044,7 +1258,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1056,7 +1277,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1070,12 +1298,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1091,12 +1325,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1110,12 +1350,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading TransitionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TriggerInvocationExpressionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TriggerInvocationExpressionReader.cs index 3f347c4a2..a4c9e8268 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TriggerInvocationExpressionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TriggerInvocationExpressionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Actions; using SysML2.NET.Core.POCO.Core.Features; @@ -44,6 +45,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -68,7 +70,8 @@ public class TriggerInvocationExpressionReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public TriggerInvocationExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public TriggerInvocationExpressionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -114,6 +117,8 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "TriggerInvocationExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -142,7 +147,7 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -269,7 +274,7 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(kindXmlAttribute)) { - if (Enum.TryParse(kindXmlAttribute, true, out TriggerKind kindXmlAttributeAsEnum)) + if (TriggerKindProvider.TryParse(kindXmlAttribute.AsSpan(), out var kindXmlAttributeAsEnum)) { poco.Kind = kindXmlAttributeAsEnum; } @@ -287,6 +292,10 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -303,6 +312,10 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -353,7 +366,14 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -377,7 +397,14 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -389,7 +416,14 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -401,7 +435,14 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -413,7 +454,14 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -425,7 +473,14 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -437,7 +492,14 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -449,7 +511,14 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -461,7 +530,14 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -473,7 +549,14 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -485,7 +568,14 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -497,7 +587,14 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -509,7 +606,14 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre if (!string.IsNullOrWhiteSpace(kindValue)) { - poco.Kind = (TriggerKind)Enum.Parse(typeof(TriggerKind), kindValue, true); + if (TriggerKindProvider.TryParse(kindValue.AsSpan(), out var kindValueAsEnum)) + { + poco.Kind = kindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'kind' on element {ElementId}", kindValue, poco.Id); + } } break; @@ -523,12 +627,18 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -544,12 +654,18 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -557,6 +673,10 @@ public override ITriggerInvocationExpression Read(XmlReader xmiReader, Uri curre break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading TriggerInvocationExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -606,6 +726,8 @@ public override async Task ReadAsync(XmlReader xmi this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "TriggerInvocationExpression", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -634,7 +756,7 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -761,7 +883,7 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(kindXmlAttribute)) { - if (Enum.TryParse(kindXmlAttribute, true, out TriggerKind kindXmlAttributeAsEnum)) + if (TriggerKindProvider.TryParse(kindXmlAttribute.AsSpan(), out var kindXmlAttributeAsEnum)) { poco.Kind = kindXmlAttributeAsEnum; } @@ -779,6 +901,10 @@ public override async Task ReadAsync(XmlReader xmi { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -795,6 +921,10 @@ public override async Task ReadAsync(XmlReader xmi { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -845,7 +975,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -869,7 +1006,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -881,7 +1025,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -893,7 +1044,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -905,7 +1063,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -917,7 +1082,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -929,7 +1101,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -941,7 +1120,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -953,7 +1139,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -965,7 +1158,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -977,7 +1177,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -989,7 +1196,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(isVariableValue)) { - poco.IsVariable = bool.Parse(isVariableValue); + if (bool.TryParse(isVariableValue, out var isVariableValueAsBool)) + { + poco.IsVariable = isVariableValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariable' on element {ElementId}", isVariableValue, poco.Id); + } } break; @@ -1001,7 +1215,14 @@ public override async Task ReadAsync(XmlReader xmi if (!string.IsNullOrWhiteSpace(kindValue)) { - poco.Kind = (TriggerKind)Enum.Parse(typeof(TriggerKind), kindValue, true); + if (TriggerKindProvider.TryParse(kindValue.AsSpan(), out var kindValueAsEnum)) + { + poco.Kind = kindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'kind' on element {ElementId}", kindValue, poco.Id); + } } break; @@ -1015,12 +1236,18 @@ public override async Task ReadAsync(XmlReader xmi { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1036,12 +1263,18 @@ public override async Task ReadAsync(XmlReader xmi { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1049,6 +1282,10 @@ public override async Task ReadAsync(XmlReader xmi break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading TriggerInvocationExpression at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TypeFeaturingReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TypeFeaturingReader.cs index 01cfae493..318b5b3da 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TypeFeaturingReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TypeFeaturingReader.cs @@ -33,11 +33,13 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Types; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -62,7 +64,8 @@ public class TypeFeaturingReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public TypeFeaturingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public TypeFeaturingReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +111,8 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "TypeFeaturing", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -147,6 +152,10 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featureOfType", featureOfTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'featureOfType' on element {ElementId}", featureOfTypeXmlAttribute, poco.Id); + } } var featuringTypeXmlAttribute = xmiReader.GetAttribute("featuringType"); @@ -157,6 +166,10 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featuringType", featuringTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'featuringType' on element {ElementId}", featuringTypeXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -191,6 +204,10 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -211,6 +228,10 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -227,6 +248,10 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -237,6 +262,10 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -301,12 +330,18 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var featureOfTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featureOfType", featureOfTypeId); + if (Guid.TryParse(hrefSplit[1], out var featureOfTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featureOfType", featureOfTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'featureOfType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var featureOfTypeValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var featureOfTypeValue = (IFeature)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.FeatureOfType = featureOfTypeValue; } @@ -322,12 +357,18 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var featuringTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featuringType", featuringTypeId); + if (Guid.TryParse(hrefSplit[1], out var featuringTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featuringType", featuringTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'featuringType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var featuringTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var featuringTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.FeaturingType = featuringTypeValue; } @@ -341,7 +382,14 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -353,7 +401,14 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -367,12 +422,18 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -388,12 +449,18 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -409,12 +476,18 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -430,12 +503,18 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -443,6 +522,10 @@ public override ITypeFeaturing Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading TypeFeaturing at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -492,6 +575,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "TypeFeaturing", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -531,6 +616,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featureOfType", featureOfTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'featureOfType' on element {ElementId}", featureOfTypeXmlAttribute, poco.Id); + } } var featuringTypeXmlAttribute = xmiReader.GetAttribute("featuringType"); @@ -541,6 +630,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featuringType", featuringTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'featuringType' on element {ElementId}", featuringTypeXmlAttribute, poco.Id); + } } var isImpliedXmlAttribute = xmiReader.GetAttribute("isImplied"); @@ -575,6 +668,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -595,6 +692,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -611,6 +712,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -621,6 +726,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -685,12 +794,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var featureOfTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featureOfType", featureOfTypeId); + if (Guid.TryParse(hrefSplit[1], out var featureOfTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featureOfType", featureOfTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'featureOfType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var featureOfTypeValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var featureOfTypeValue = (IFeature)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.FeatureOfType = featureOfTypeValue; } @@ -706,12 +821,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var featuringTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featuringType", featuringTypeId); + if (Guid.TryParse(hrefSplit[1], out var featuringTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "featuringType", featuringTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'featuringType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var featuringTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var featuringTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.FeaturingType = featuringTypeValue; } @@ -725,7 +846,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -737,7 +865,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -751,12 +886,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -772,12 +913,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -793,12 +940,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -814,12 +967,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -827,6 +986,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cu break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading TypeFeaturing at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TypeReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TypeReader.cs index db0fd0dbb..f73316b15 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TypeReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/TypeReader.cs @@ -33,11 +33,13 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -62,7 +64,8 @@ public class TypeReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public TypeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public TypeReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +111,8 @@ public override IType Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Type", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -181,6 +186,10 @@ public override IType Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -197,6 +206,10 @@ public override IType Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -259,7 +272,14 @@ public override IType Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -271,7 +291,14 @@ public override IType Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -283,7 +310,14 @@ public override IType Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -297,12 +331,18 @@ public override IType Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -318,12 +358,18 @@ public override IType Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -331,6 +377,10 @@ public override IType Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Type at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -380,6 +430,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Type", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -453,6 +505,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -469,6 +525,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -531,7 +591,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -543,7 +610,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -555,7 +629,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -569,12 +650,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -590,12 +677,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -603,6 +696,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoca break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Type at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UnioningReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UnioningReader.cs index c7e4f894e..d8de398c7 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UnioningReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UnioningReader.cs @@ -33,10 +33,12 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -61,7 +63,8 @@ public class UnioningReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public UnioningReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public UnioningReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -107,6 +110,8 @@ public override IUnioning Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Unioning", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -170,6 +175,10 @@ public override IUnioning Read(XmlReader xmiReader, Uri currentLocation) { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -190,6 +199,10 @@ public override IUnioning Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -206,6 +219,10 @@ public override IUnioning Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -216,6 +233,10 @@ public override IUnioning Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var unioningTypeXmlAttribute = xmiReader.GetAttribute("unioningType"); @@ -226,6 +247,10 @@ public override IUnioning Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "unioningType", unioningTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'unioningType' on element {ElementId}", unioningTypeXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -288,7 +313,14 @@ public override IUnioning Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -300,7 +332,14 @@ public override IUnioning Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -314,12 +353,18 @@ public override IUnioning Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -335,12 +380,18 @@ public override IUnioning Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -356,12 +407,18 @@ public override IUnioning Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -377,12 +434,18 @@ public override IUnioning Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -398,12 +461,18 @@ public override IUnioning Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var unioningTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "unioningType", unioningTypeId); + if (Guid.TryParse(hrefSplit[1], out var unioningTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "unioningType", unioningTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'unioningType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var unioningTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var unioningTypeValue = (IType)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.UnioningType = unioningTypeValue; } @@ -411,6 +480,10 @@ public override IUnioning Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Unioning at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -460,6 +533,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Unioning", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -523,6 +598,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -543,6 +622,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -559,6 +642,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -569,6 +656,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var unioningTypeXmlAttribute = xmiReader.GetAttribute("unioningType"); @@ -579,6 +670,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "unioningType", unioningTypeXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'unioningType' on element {ElementId}", unioningTypeXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -641,7 +736,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -653,7 +755,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -667,12 +776,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -688,12 +803,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -709,12 +830,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -730,12 +857,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -751,12 +884,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var unioningTypeId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "unioningType", unioningTypeId); + if (Guid.TryParse(hrefSplit[1], out var unioningTypeId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "unioningType", unioningTypeId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'unioningType' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var unioningTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var unioningTypeValue = (IType)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); poco.UnioningType = unioningTypeValue; } @@ -764,6 +903,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri current break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Unioning at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UsageReader.cs index 865b63a25..c5d989531 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; @@ -62,6 +63,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -86,7 +88,8 @@ public class UsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public UsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public UsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -132,6 +135,8 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Usage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -160,7 +165,7 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -295,6 +300,10 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -311,6 +320,10 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -361,7 +374,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -385,7 +405,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -397,7 +424,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -409,7 +443,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -421,7 +462,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -433,7 +481,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -445,7 +500,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -457,7 +519,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -469,7 +538,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -481,7 +557,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -493,7 +576,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -505,7 +595,14 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -519,12 +616,18 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -540,12 +643,18 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -553,6 +662,10 @@ public override IUsage Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Usage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -602,6 +715,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "Usage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -630,7 +745,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -765,6 +880,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -781,6 +900,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -831,7 +954,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -855,7 +985,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -867,7 +1004,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -879,7 +1023,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -891,7 +1042,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -903,7 +1061,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -915,7 +1080,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -927,7 +1099,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -939,7 +1118,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -951,7 +1137,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -963,7 +1156,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -975,7 +1175,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -989,12 +1196,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1010,12 +1223,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1023,6 +1242,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri currentLoc break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading Usage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UseCaseDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UseCaseDefinitionReader.cs index 1798abe05..314ec9ed9 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UseCaseDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UseCaseDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -63,6 +64,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -87,7 +89,8 @@ public class UseCaseDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public UseCaseDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public UseCaseDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -133,6 +136,8 @@ public override IUseCaseDefinition Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "UseCaseDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -226,6 +231,10 @@ public override IUseCaseDefinition Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -242,6 +251,10 @@ public override IUseCaseDefinition Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -304,7 +317,14 @@ public override IUseCaseDefinition Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -316,7 +336,14 @@ public override IUseCaseDefinition Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -328,7 +355,14 @@ public override IUseCaseDefinition Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -340,7 +374,14 @@ public override IUseCaseDefinition Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -352,7 +393,14 @@ public override IUseCaseDefinition Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -366,12 +414,18 @@ public override IUseCaseDefinition Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -387,12 +441,18 @@ public override IUseCaseDefinition Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -400,6 +460,10 @@ public override IUseCaseDefinition Read(XmlReader xmiReader, Uri currentLocation break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading UseCaseDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -449,6 +513,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "UseCaseDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -542,6 +608,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -558,6 +628,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -620,7 +694,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -632,7 +713,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -644,7 +732,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -656,7 +751,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -668,7 +770,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -682,12 +791,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -703,12 +818,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -716,6 +837,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading UseCaseDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UseCaseUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UseCaseUsageReader.cs index a3c5ccf7d..f6865c7d4 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UseCaseUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/UseCaseUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class UseCaseUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public UseCaseUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public UseCaseUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "UseCaseUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override IUseCaseUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading UseCaseUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "UseCaseUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri cur if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading UseCaseUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/VariantMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/VariantMembershipReader.cs index e11f62813..f2d1dd050 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/VariantMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/VariantMembershipReader.cs @@ -33,11 +33,13 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Root.Annotations; using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -62,7 +64,8 @@ public class VariantMembershipReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public VariantMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public VariantMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -108,6 +111,8 @@ public override IVariantMembership Read(XmlReader xmiReader, Uri currentLocation this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "VariantMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -171,6 +176,10 @@ public override IVariantMembership Read(XmlReader xmiReader, Uri currentLocation { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -191,6 +200,10 @@ public override IVariantMembership Read(XmlReader xmiReader, Uri currentLocation { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -207,6 +220,10 @@ public override IVariantMembership Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -217,13 +234,17 @@ public override IVariantMembership Read(XmlReader xmiReader, Uri currentLocation { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -289,7 +310,14 @@ public override IVariantMembership Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -301,7 +329,14 @@ public override IVariantMembership Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -315,12 +350,18 @@ public override IVariantMembership Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -336,12 +377,18 @@ public override IVariantMembership Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -357,12 +404,18 @@ public override IVariantMembership Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -378,12 +431,18 @@ public override IVariantMembership Read(XmlReader xmiReader, Uri currentLocation { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -397,12 +456,23 @@ public override IVariantMembership Read(XmlReader xmiReader, Uri currentLocation if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading VariantMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -452,6 +522,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "VariantMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -515,6 +587,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -535,6 +611,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -551,6 +631,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -561,13 +645,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -633,7 +721,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -645,7 +740,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -659,12 +761,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -680,12 +788,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -701,12 +815,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -722,12 +842,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -741,12 +867,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Ur if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading VariantMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/VerificationCaseDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/VerificationCaseDefinitionReader.cs index d66274707..bc8428eb9 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/VerificationCaseDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/VerificationCaseDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -63,6 +64,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.UseCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -87,7 +89,8 @@ public class VerificationCaseDefinitionReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public VerificationCaseDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public VerificationCaseDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -133,6 +136,8 @@ public override IVerificationCaseDefinition Read(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "VerificationCaseDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -226,6 +231,10 @@ public override IVerificationCaseDefinition Read(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -242,6 +251,10 @@ public override IVerificationCaseDefinition Read(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -304,7 +317,14 @@ public override IVerificationCaseDefinition Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -316,7 +336,14 @@ public override IVerificationCaseDefinition Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -328,7 +355,14 @@ public override IVerificationCaseDefinition Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -340,7 +374,14 @@ public override IVerificationCaseDefinition Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -352,7 +393,14 @@ public override IVerificationCaseDefinition Read(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -366,12 +414,18 @@ public override IVerificationCaseDefinition Read(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -387,12 +441,18 @@ public override IVerificationCaseDefinition Read(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -400,6 +460,10 @@ public override IVerificationCaseDefinition Read(XmlReader xmiReader, Uri curren break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading VerificationCaseDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -449,6 +513,8 @@ public override async Task ReadAsync(XmlReader xmiR this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "VerificationCaseDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -542,6 +608,10 @@ public override async Task ReadAsync(XmlReader xmiR { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -558,6 +628,10 @@ public override async Task ReadAsync(XmlReader xmiR { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -620,7 +694,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -632,7 +713,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -644,7 +732,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -656,7 +751,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -668,7 +770,14 @@ public override async Task ReadAsync(XmlReader xmiR if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -682,12 +791,18 @@ public override async Task ReadAsync(XmlReader xmiR { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -703,12 +818,18 @@ public override async Task ReadAsync(XmlReader xmiR { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -716,6 +837,10 @@ public override async Task ReadAsync(XmlReader xmiR break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading VerificationCaseDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/VerificationCaseUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/VerificationCaseUsageReader.cs index 4530f24c2..1b2bc075a 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/VerificationCaseUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/VerificationCaseUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.UseCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class VerificationCaseUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public VerificationCaseUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public VerificationCaseUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "VerificationCaseUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override IVerificationCaseUsage Read(XmlReader xmiReader, Uri currentLoca if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading VerificationCaseUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "VerificationCaseUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading VerificationCaseUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewDefinitionReader.cs index 3e601b92c..2cac3d9d2 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -62,6 +63,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.UseCases; using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -86,7 +88,8 @@ public class ViewDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ViewDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ViewDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -132,6 +135,8 @@ public override IViewDefinition Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ViewDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -225,6 +230,10 @@ public override IViewDefinition Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -241,6 +250,10 @@ public override IViewDefinition Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (xmiReader.Read()) @@ -303,7 +316,14 @@ public override IViewDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -315,7 +335,14 @@ public override IViewDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -327,7 +354,14 @@ public override IViewDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -339,7 +373,14 @@ public override IViewDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -351,7 +392,14 @@ public override IViewDefinition Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -365,12 +413,18 @@ public override IViewDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -386,12 +440,18 @@ public override IViewDefinition Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -399,6 +459,10 @@ public override IViewDefinition Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ViewDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -448,6 +512,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ViewDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -541,6 +607,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -557,6 +627,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } while (await xmiReader.ReadAsync()) @@ -619,7 +693,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -631,7 +712,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -643,7 +731,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -655,7 +750,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -667,7 +769,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -681,12 +790,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -702,12 +817,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -715,6 +836,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ViewDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewRenderingMembershipReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewRenderingMembershipReader.cs index 4dcdbf570..1a98b1186 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewRenderingMembershipReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewRenderingMembershipReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Root.Namespaces; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -40,6 +41,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Root.Elements; using SysML2.NET.Core.POCO.Root.Namespaces; using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -64,7 +66,8 @@ public class ViewRenderingMembershipReader : XmiDataReader /// The injected used to register and process external references /// The injected used to set up logging - public ViewRenderingMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ViewRenderingMembershipReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -110,6 +113,8 @@ public override IViewRenderingMembership Read(XmlReader xmiReader, Uri currentLo this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ViewRenderingMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -173,6 +178,10 @@ public override IViewRenderingMembership Read(XmlReader xmiReader, Uri currentLo { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -193,6 +202,10 @@ public override IViewRenderingMembership Read(XmlReader xmiReader, Uri currentLo { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -209,6 +222,10 @@ public override IViewRenderingMembership Read(XmlReader xmiReader, Uri currentLo { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -219,13 +236,17 @@ public override IViewRenderingMembership Read(XmlReader xmiReader, Uri currentLo { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -291,7 +312,14 @@ public override IViewRenderingMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -303,7 +331,14 @@ public override IViewRenderingMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -317,12 +352,18 @@ public override IViewRenderingMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -338,12 +379,18 @@ public override IViewRenderingMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -359,12 +406,18 @@ public override IViewRenderingMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -380,12 +433,18 @@ public override IViewRenderingMembership Read(XmlReader xmiReader, Uri currentLo { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -399,12 +458,23 @@ public override IViewRenderingMembership Read(XmlReader xmiReader, Uri currentLo if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ViewRenderingMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -454,6 +524,8 @@ public override async Task ReadAsync(XmlReader xmiRead this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ViewRenderingMembership", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -517,6 +589,10 @@ public override async Task ReadAsync(XmlReader xmiRead { ownedRelatedElementXmlAttributeReferences.Add(ownedRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelatedElement' on element {ElementId}", ownedRelatedElementXmlAttributeValue, poco.Id); + } } if (ownedRelatedElementXmlAttributeReferences.Count != 0) @@ -537,6 +613,10 @@ public override async Task ReadAsync(XmlReader xmiRead { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -553,6 +633,10 @@ public override async Task ReadAsync(XmlReader xmiRead { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelatedElement' on element {ElementId}", owningRelatedElementXmlAttribute, poco.Id); + } } var owningRelationshipXmlAttribute = xmiReader.GetAttribute("owningRelationship"); @@ -563,13 +647,17 @@ public override async Task ReadAsync(XmlReader xmiRead { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var visibilityXmlAttribute = xmiReader.GetAttribute("visibility"); if (!string.IsNullOrWhiteSpace(visibilityXmlAttribute)) { - if (Enum.TryParse(visibilityXmlAttribute, true, out VisibilityKind visibilityXmlAttributeAsEnum)) + if (VisibilityKindProvider.TryParse(visibilityXmlAttribute.AsSpan(), out var visibilityXmlAttributeAsEnum)) { poco.Visibility = visibilityXmlAttributeAsEnum; } @@ -635,7 +723,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isImpliedValue)) { - poco.IsImplied = bool.Parse(isImpliedValue); + if (bool.TryParse(isImpliedValue, out var isImpliedValueAsBool)) + { + poco.IsImplied = isImpliedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImplied' on element {ElementId}", isImpliedValue, poco.Id); + } } break; @@ -647,7 +742,14 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -661,12 +763,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelatedElementId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelatedElement", ownedRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwnedRelatedElement.Add(ownedRelatedElementValue); } @@ -682,12 +790,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -703,12 +817,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelatedElementId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + if (Guid.TryParse(hrefSplit[1], out var owningRelatedElementId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelatedElement", owningRelatedElementId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelatedElement' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelatedElementValue = (IElement)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedRelationship)poco).OwningRelatedElement = owningRelatedElementValue; } @@ -724,12 +844,18 @@ public override async Task ReadAsync(XmlReader xmiRead { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -743,12 +869,23 @@ public override async Task ReadAsync(XmlReader xmiRead if (!string.IsNullOrWhiteSpace(visibilityValue)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); + if (VisibilityKindProvider.TryParse(visibilityValue.AsSpan(), out var visibilityValueAsEnum)) + { + poco.Visibility = visibilityValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'visibility' on element {ElementId}", visibilityValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ViewRenderingMembership at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewUsageReader.cs index b1455282f..1257941f2 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.UseCases; using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class ViewUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ViewUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ViewUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ViewUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override IViewUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ViewUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ViewUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri curren if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ViewUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewpointDefinitionReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewpointDefinitionReader.cs index 3ae0c84df..b5093a24d 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewpointDefinitionReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewpointDefinitionReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.POCO.Core.Classifiers; using SysML2.NET.Core.POCO.Core.Features; using SysML2.NET.Core.POCO.Core.Types; @@ -63,6 +64,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.UseCases; using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -87,7 +89,8 @@ public class ViewpointDefinitionReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ViewpointDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ViewpointDefinitionReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -133,6 +136,8 @@ public override IViewpointDefinition Read(XmlReader xmiReader, Uri currentLocati this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ViewpointDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -219,6 +224,10 @@ public override IViewpointDefinition Read(XmlReader xmiReader, Uri currentLocati { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -235,6 +244,10 @@ public override IViewpointDefinition Read(XmlReader xmiReader, Uri currentLocati { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var reqIdXmlAttribute = xmiReader.GetAttribute("reqId"); @@ -292,7 +305,14 @@ public override IViewpointDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -304,7 +324,14 @@ public override IViewpointDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -316,7 +343,14 @@ public override IViewpointDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -328,7 +362,14 @@ public override IViewpointDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -340,7 +381,14 @@ public override IViewpointDefinition Read(XmlReader xmiReader, Uri currentLocati if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -354,12 +402,18 @@ public override IViewpointDefinition Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -375,12 +429,18 @@ public override IViewpointDefinition Read(XmlReader xmiReader, Uri currentLocati { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -400,6 +460,10 @@ public override IViewpointDefinition Read(XmlReader xmiReader, Uri currentLocati break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ViewpointDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -449,6 +513,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ViewpointDefinition", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -535,6 +601,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -551,6 +621,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var reqIdXmlAttribute = xmiReader.GetAttribute("reqId"); @@ -608,7 +682,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -620,7 +701,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -632,7 +720,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -644,7 +739,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -656,7 +758,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -670,12 +779,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -691,12 +806,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -716,6 +837,10 @@ public override async Task ReadAsync(XmlReader xmiReader, break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ViewpointDefinition at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewpointUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewpointUsageReader.cs index f963fc233..33962869e 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewpointUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/ViewpointUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.UseCases; using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class ViewpointUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public ViewpointUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public ViewpointUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ViewpointUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -157,7 +162,7 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -302,6 +307,10 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -318,13 +327,17 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -373,7 +386,14 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -397,7 +417,14 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -409,7 +436,14 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -421,7 +455,14 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -433,7 +474,14 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -445,7 +493,14 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -457,7 +512,14 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -469,7 +531,14 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -481,7 +550,14 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -493,7 +569,14 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -505,7 +588,14 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -517,7 +607,14 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -529,7 +626,14 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -543,12 +647,18 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -564,12 +674,18 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -583,7 +699,14 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; @@ -601,6 +724,10 @@ public override IViewpointUsage Read(XmlReader xmiReader, Uri currentLocation) break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ViewpointUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "ViewpointUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -671,7 +800,7 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -816,6 +945,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -832,13 +965,17 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -887,7 +1024,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -911,7 +1055,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -923,7 +1074,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -935,7 +1093,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -947,7 +1112,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -959,7 +1131,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -971,7 +1150,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -983,7 +1169,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -995,7 +1188,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1007,7 +1207,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1019,7 +1226,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1031,7 +1245,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1043,7 +1264,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1057,12 +1285,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1078,12 +1312,18 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1097,7 +1337,14 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; @@ -1115,6 +1362,10 @@ public override async Task ReadAsync(XmlReader xmiReader, Uri c break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading ViewpointUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/WhileLoopActionUsageReader.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/WhileLoopActionUsageReader.cs index 3c74d4f4c..b8ff88716 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/WhileLoopActionUsageReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/WhileLoopActionUsageReader.cs @@ -33,6 +33,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using Microsoft.Extensions.Logging.Abstractions; using SysML2.NET.Common; + using SysML2.NET.Extensions.Core; using SysML2.NET.Core.Core.Types; using SysML2.NET.Core.Systems.Occurrences; using SysML2.NET.Core.POCO.Core.Classifiers; @@ -66,6 +67,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers using SysML2.NET.Core.POCO.Systems.VerificationCases; using SysML2.NET.Core.POCO.Systems.Views; using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; /// /// The purpose of the is to read an instance of @@ -90,7 +92,8 @@ public class WhileLoopActionUsageReader : XmiDataReader /// /// The injected used to register and process external references /// The injected used to set up logging - public WhileLoopActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory) + /// The optional used to track element-to-file associations + public WhileLoopActionUsageReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) : base(cache, xmiDataReaderFacade, externalReferenceService, loggerFactory, elementOriginMap) { this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); } @@ -136,6 +139,8 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "WhileLoopActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -164,7 +169,7 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -309,6 +314,10 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -325,13 +334,17 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -385,7 +398,14 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -409,7 +429,14 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -421,7 +448,14 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -433,7 +467,14 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -445,7 +486,14 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -457,7 +505,14 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -469,7 +524,14 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -481,7 +543,14 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -493,7 +562,14 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -505,7 +581,14 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -517,7 +600,14 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -529,7 +619,14 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -541,7 +638,14 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -555,12 +659,18 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -576,12 +686,18 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)this.XmiDataReaderFacade.QueryXmiData(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -595,12 +711,23 @@ public override IWhileLoopActionUsage Read(XmlReader xmiReader, Uri currentLocat if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading WhileLoopActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + xmiReader.Skip(); + break; } } } @@ -650,6 +777,8 @@ public override async Task ReadAsync(XmlReader xmiReader, this.logger.LogCritical("Failed to add element type [{Poco}] with id [{Id}] as it was already in the Cache. The XMI document seems to have duplicate xmi:id values", "WhileLoopActionUsage", poco.Id); } + this.ElementOriginMap?.Register(poco.Id, currentLocation); + var aliasIdsXmlAttribute = xmiReader.GetAttribute("aliasIds"); if (!string.IsNullOrWhiteSpace(aliasIdsXmlAttribute)) @@ -678,7 +807,7 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(directionXmlAttribute)) { - if (Enum.TryParse(directionXmlAttribute, true, out FeatureDirectionKind directionXmlAttributeAsEnum)) + if (FeatureDirectionKindProvider.TryParse(directionXmlAttribute.AsSpan(), out var directionXmlAttributeAsEnum)) { poco.Direction = directionXmlAttributeAsEnum; } @@ -823,6 +952,10 @@ public override async Task ReadAsync(XmlReader xmiReader, { ownedRelationshipXmlAttributeReferences.Add(ownedRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'ownedRelationship' on element {ElementId}", ownedRelationshipXmlAttributeValue, poco.Id); + } } if (ownedRelationshipXmlAttributeReferences.Count != 0) @@ -839,13 +972,17 @@ public override async Task ReadAsync(XmlReader xmiReader, { this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipXmlAttributeReference); } + else + { + this.logger.LogWarning("Failed to parse GUID reference value '{Value}' for property 'owningRelationship' on element {ElementId}", owningRelationshipXmlAttribute, poco.Id); + } } var portionKindXmlAttribute = xmiReader.GetAttribute("portionKind"); if (!string.IsNullOrWhiteSpace(portionKindXmlAttribute)) { - if (Enum.TryParse(portionKindXmlAttribute, true, out PortionKind portionKindXmlAttributeAsEnum)) + if (PortionKindProvider.TryParse(portionKindXmlAttribute.AsSpan(), out var portionKindXmlAttributeAsEnum)) { poco.PortionKind = portionKindXmlAttributeAsEnum; } @@ -899,7 +1036,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(directionValue)) { - poco.Direction = (FeatureDirectionKind)Enum.Parse(typeof(FeatureDirectionKind), directionValue, true); + if (FeatureDirectionKindProvider.TryParse(directionValue.AsSpan(), out var directionValueAsEnum)) + { + poco.Direction = directionValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'direction' on element {ElementId}", directionValue, poco.Id); + } } break; @@ -923,7 +1067,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isAbstractValue)) { - poco.IsAbstract = bool.Parse(isAbstractValue); + if (bool.TryParse(isAbstractValue, out var isAbstractValueAsBool)) + { + poco.IsAbstract = isAbstractValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isAbstract' on element {ElementId}", isAbstractValue, poco.Id); + } } break; @@ -935,7 +1086,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isCompositeValue)) { - poco.IsComposite = bool.Parse(isCompositeValue); + if (bool.TryParse(isCompositeValue, out var isCompositeValueAsBool)) + { + poco.IsComposite = isCompositeValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isComposite' on element {ElementId}", isCompositeValue, poco.Id); + } } break; @@ -947,7 +1105,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isConstantValue)) { - poco.IsConstant = bool.Parse(isConstantValue); + if (bool.TryParse(isConstantValue, out var isConstantValueAsBool)) + { + poco.IsConstant = isConstantValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isConstant' on element {ElementId}", isConstantValue, poco.Id); + } } break; @@ -959,7 +1124,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isDerivedValue)) { - poco.IsDerived = bool.Parse(isDerivedValue); + if (bool.TryParse(isDerivedValue, out var isDerivedValueAsBool)) + { + poco.IsDerived = isDerivedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isDerived' on element {ElementId}", isDerivedValue, poco.Id); + } } break; @@ -971,7 +1143,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isEndValue)) { - poco.IsEnd = bool.Parse(isEndValue); + if (bool.TryParse(isEndValue, out var isEndValueAsBool)) + { + poco.IsEnd = isEndValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isEnd' on element {ElementId}", isEndValue, poco.Id); + } } break; @@ -983,7 +1162,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isImpliedIncludedValue)) { - poco.IsImpliedIncluded = bool.Parse(isImpliedIncludedValue); + if (bool.TryParse(isImpliedIncludedValue, out var isImpliedIncludedValueAsBool)) + { + poco.IsImpliedIncluded = isImpliedIncludedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isImpliedIncluded' on element {ElementId}", isImpliedIncludedValue, poco.Id); + } } break; @@ -995,7 +1181,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isIndividualValue)) { - poco.IsIndividual = bool.Parse(isIndividualValue); + if (bool.TryParse(isIndividualValue, out var isIndividualValueAsBool)) + { + poco.IsIndividual = isIndividualValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isIndividual' on element {ElementId}", isIndividualValue, poco.Id); + } } break; @@ -1007,7 +1200,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isOrderedValue)) { - poco.IsOrdered = bool.Parse(isOrderedValue); + if (bool.TryParse(isOrderedValue, out var isOrderedValueAsBool)) + { + poco.IsOrdered = isOrderedValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isOrdered' on element {ElementId}", isOrderedValue, poco.Id); + } } break; @@ -1019,7 +1219,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isPortionValue)) { - poco.IsPortion = bool.Parse(isPortionValue); + if (bool.TryParse(isPortionValue, out var isPortionValueAsBool)) + { + poco.IsPortion = isPortionValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isPortion' on element {ElementId}", isPortionValue, poco.Id); + } } break; @@ -1031,7 +1238,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isSufficientValue)) { - poco.IsSufficient = bool.Parse(isSufficientValue); + if (bool.TryParse(isSufficientValue, out var isSufficientValueAsBool)) + { + poco.IsSufficient = isSufficientValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isSufficient' on element {ElementId}", isSufficientValue, poco.Id); + } } break; @@ -1043,7 +1257,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isUniqueValue)) { - poco.IsUnique = bool.Parse(isUniqueValue); + if (bool.TryParse(isUniqueValue, out var isUniqueValueAsBool)) + { + poco.IsUnique = isUniqueValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isUnique' on element {ElementId}", isUniqueValue, poco.Id); + } } break; @@ -1055,7 +1276,14 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(isVariationValue)) { - poco.IsVariation = bool.Parse(isVariationValue); + if (bool.TryParse(isVariationValue, out var isVariationValueAsBool)) + { + poco.IsVariation = isVariationValueAsBool; + } + else + { + this.logger.LogWarning("Failed to parse bool value '{Value}' for property 'isVariation' on element {ElementId}", isVariationValue, poco.Id); + } } break; @@ -1069,12 +1297,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var ownedRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var ownedRelationshipId)) + { + this.Cache.AddMultipleValueReferencePropertyIdentifiers(poco.Id, "ownedRelationship", ownedRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'ownedRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var ownedRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwnedRelationship.Add(ownedRelationshipValue); } @@ -1090,12 +1324,18 @@ public override async Task ReadAsync(XmlReader xmiReader, { var hrefSplit = hrefAttribute.Split('#'); this.ExternalReferenceService.AddExternalReferenceToProcess(currentLocation, hrefSplit[0]); - var owningRelationshipId = Guid.Parse(hrefSplit[1]); - this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + if (Guid.TryParse(hrefSplit[1], out var owningRelationshipId)) + { + this.Cache.AddSingleValueReferencePropertyIdentifier(poco.Id, "owningRelationship", owningRelationshipId); + } + else + { + this.logger.LogWarning("Failed to parse href GUID value '{HrefValue}' for property 'owningRelationship' on element {ElementId}", hrefSplit[1], poco.Id); + } } else { - var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory); + var owningRelationshipValue = (IRelationship)await this.XmiDataReaderFacade.QueryXmiDataAsync(xmiReader, this.Cache, currentLocation, this.ExternalReferenceService, this.LoggerFactory, elementOriginMap: this.ElementOriginMap); ((IContainedElement)poco).OwningRelationship = owningRelationshipValue; } @@ -1109,12 +1349,23 @@ public override async Task ReadAsync(XmlReader xmiReader, if (!string.IsNullOrWhiteSpace(portionKindValue)) { - poco.PortionKind = (PortionKind)Enum.Parse(typeof(PortionKind), portionKindValue, true); + if (PortionKindProvider.TryParse(portionKindValue.AsSpan(), out var portionKindValueAsEnum)) + { + poco.PortionKind = portionKindValueAsEnum; + } + else + { + this.logger.LogWarning("Failed to parse enum value '{Value}' for property 'portionKind' on element {ElementId}", portionKindValue, poco.Id); + } } break; } + default: + this.logger.LogWarning("Unexpected element '{LocalName}' encountered while reading WhileLoopActionUsage at line:position {LineNumber}:{LinePosition}", xmiReader.LocalName, xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition); + await xmiReader.SkipAsync(); + break; } } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/XmiDataReaderFacade.cs b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/XmiDataReaderFacade.cs index c34da7c54..aef36854c 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/XmiDataReaderFacade.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/AutoGenReaders/XmiDataReaderFacade.cs @@ -44,2027 +44,2027 @@ public class XmiDataReaderFacade : IXmiDataReaderFacade /// A dictionary that contains functions that return based a key that represents the xsi Type /// and a provided , , and /// - private readonly Dictionary> readerCache; + private readonly Dictionary> readerCache; /// /// A dictionary that contains functions that return an awaitable with the based a key that represents the xsi Type /// and a provided , , and /// - private readonly Dictionary>> readerAsyncCache; + private readonly Dictionary>> readerAsyncCache; /// /// Initializes a new instance of the /// public XmiDataReaderFacade() { - this.readerCache = new Dictionary> + this.readerCache = new Dictionary> { - ["sysml:AcceptActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AcceptActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var acceptActionUsageReader = new AcceptActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var acceptActionUsageReader = new AcceptActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return acceptActionUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:ActionDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ActionDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var actionDefinitionReader = new ActionDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var actionDefinitionReader = new ActionDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return actionDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:ActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var actionUsageReader = new ActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var actionUsageReader = new ActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return actionUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:ActorMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ActorMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var actorMembershipReader = new ActorMembershipReader(cache, this, externalReferenceService, loggerFactory); + var actorMembershipReader = new ActorMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return actorMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:AllocationDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AllocationDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var allocationDefinitionReader = new AllocationDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var allocationDefinitionReader = new AllocationDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return allocationDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:AllocationUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AllocationUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var allocationUsageReader = new AllocationUsageReader(cache, this, externalReferenceService, loggerFactory); + var allocationUsageReader = new AllocationUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return allocationUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:AnalysisCaseDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AnalysisCaseDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var analysisCaseDefinitionReader = new AnalysisCaseDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var analysisCaseDefinitionReader = new AnalysisCaseDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return analysisCaseDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:AnalysisCaseUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AnalysisCaseUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var analysisCaseUsageReader = new AnalysisCaseUsageReader(cache, this, externalReferenceService, loggerFactory); + var analysisCaseUsageReader = new AnalysisCaseUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return analysisCaseUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:AnnotatingElement"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AnnotatingElement"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var annotatingElementReader = new AnnotatingElementReader(cache, this, externalReferenceService, loggerFactory); + var annotatingElementReader = new AnnotatingElementReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return annotatingElementReader.Read(subXmlReader, currentLocation); }, - ["sysml:Annotation"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Annotation"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var annotationReader = new AnnotationReader(cache, this, externalReferenceService, loggerFactory); + var annotationReader = new AnnotationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return annotationReader.Read(subXmlReader, currentLocation); }, - ["sysml:AssertConstraintUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AssertConstraintUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var assertConstraintUsageReader = new AssertConstraintUsageReader(cache, this, externalReferenceService, loggerFactory); + var assertConstraintUsageReader = new AssertConstraintUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return assertConstraintUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:AssignmentActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AssignmentActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var assignmentActionUsageReader = new AssignmentActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var assignmentActionUsageReader = new AssignmentActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return assignmentActionUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:Association"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Association"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var associationReader = new AssociationReader(cache, this, externalReferenceService, loggerFactory); + var associationReader = new AssociationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return associationReader.Read(subXmlReader, currentLocation); }, - ["sysml:AssociationStructure"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AssociationStructure"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var associationStructureReader = new AssociationStructureReader(cache, this, externalReferenceService, loggerFactory); + var associationStructureReader = new AssociationStructureReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return associationStructureReader.Read(subXmlReader, currentLocation); }, - ["sysml:AttributeDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AttributeDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var attributeDefinitionReader = new AttributeDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var attributeDefinitionReader = new AttributeDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return attributeDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:AttributeUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AttributeUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var attributeUsageReader = new AttributeUsageReader(cache, this, externalReferenceService, loggerFactory); + var attributeUsageReader = new AttributeUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return attributeUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:Behavior"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Behavior"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var behaviorReader = new BehaviorReader(cache, this, externalReferenceService, loggerFactory); + var behaviorReader = new BehaviorReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return behaviorReader.Read(subXmlReader, currentLocation); }, - ["sysml:BindingConnector"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:BindingConnector"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var bindingConnectorReader = new BindingConnectorReader(cache, this, externalReferenceService, loggerFactory); + var bindingConnectorReader = new BindingConnectorReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return bindingConnectorReader.Read(subXmlReader, currentLocation); }, - ["sysml:BindingConnectorAsUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:BindingConnectorAsUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var bindingConnectorAsUsageReader = new BindingConnectorAsUsageReader(cache, this, externalReferenceService, loggerFactory); + var bindingConnectorAsUsageReader = new BindingConnectorAsUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return bindingConnectorAsUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:BooleanExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:BooleanExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var booleanExpressionReader = new BooleanExpressionReader(cache, this, externalReferenceService, loggerFactory); + var booleanExpressionReader = new BooleanExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return booleanExpressionReader.Read(subXmlReader, currentLocation); }, - ["sysml:CalculationDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:CalculationDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var calculationDefinitionReader = new CalculationDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var calculationDefinitionReader = new CalculationDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return calculationDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:CalculationUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:CalculationUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var calculationUsageReader = new CalculationUsageReader(cache, this, externalReferenceService, loggerFactory); + var calculationUsageReader = new CalculationUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return calculationUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:CaseDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:CaseDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var caseDefinitionReader = new CaseDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var caseDefinitionReader = new CaseDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return caseDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:CaseUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:CaseUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var caseUsageReader = new CaseUsageReader(cache, this, externalReferenceService, loggerFactory); + var caseUsageReader = new CaseUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return caseUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:Class"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Class"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var classReader = new ClassReader(cache, this, externalReferenceService, loggerFactory); + var classReader = new ClassReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return classReader.Read(subXmlReader, currentLocation); }, - ["sysml:Classifier"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Classifier"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var classifierReader = new ClassifierReader(cache, this, externalReferenceService, loggerFactory); + var classifierReader = new ClassifierReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return classifierReader.Read(subXmlReader, currentLocation); }, - ["sysml:CollectExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:CollectExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var collectExpressionReader = new CollectExpressionReader(cache, this, externalReferenceService, loggerFactory); + var collectExpressionReader = new CollectExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return collectExpressionReader.Read(subXmlReader, currentLocation); }, - ["sysml:Comment"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Comment"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var commentReader = new CommentReader(cache, this, externalReferenceService, loggerFactory); + var commentReader = new CommentReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return commentReader.Read(subXmlReader, currentLocation); }, - ["sysml:ConcernDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConcernDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var concernDefinitionReader = new ConcernDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var concernDefinitionReader = new ConcernDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return concernDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:ConcernUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConcernUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var concernUsageReader = new ConcernUsageReader(cache, this, externalReferenceService, loggerFactory); + var concernUsageReader = new ConcernUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return concernUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:ConjugatedPortDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConjugatedPortDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var conjugatedPortDefinitionReader = new ConjugatedPortDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var conjugatedPortDefinitionReader = new ConjugatedPortDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return conjugatedPortDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:ConjugatedPortTyping"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConjugatedPortTyping"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var conjugatedPortTypingReader = new ConjugatedPortTypingReader(cache, this, externalReferenceService, loggerFactory); + var conjugatedPortTypingReader = new ConjugatedPortTypingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return conjugatedPortTypingReader.Read(subXmlReader, currentLocation); }, - ["sysml:Conjugation"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Conjugation"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var conjugationReader = new ConjugationReader(cache, this, externalReferenceService, loggerFactory); + var conjugationReader = new ConjugationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return conjugationReader.Read(subXmlReader, currentLocation); }, - ["sysml:ConnectionDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConnectionDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var connectionDefinitionReader = new ConnectionDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var connectionDefinitionReader = new ConnectionDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return connectionDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:ConnectionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConnectionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var connectionUsageReader = new ConnectionUsageReader(cache, this, externalReferenceService, loggerFactory); + var connectionUsageReader = new ConnectionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return connectionUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:Connector"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Connector"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var connectorReader = new ConnectorReader(cache, this, externalReferenceService, loggerFactory); + var connectorReader = new ConnectorReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return connectorReader.Read(subXmlReader, currentLocation); }, - ["sysml:ConstraintDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConstraintDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var constraintDefinitionReader = new ConstraintDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var constraintDefinitionReader = new ConstraintDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return constraintDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:ConstraintUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConstraintUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var constraintUsageReader = new ConstraintUsageReader(cache, this, externalReferenceService, loggerFactory); + var constraintUsageReader = new ConstraintUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return constraintUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:ConstructorExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConstructorExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var constructorExpressionReader = new ConstructorExpressionReader(cache, this, externalReferenceService, loggerFactory); + var constructorExpressionReader = new ConstructorExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return constructorExpressionReader.Read(subXmlReader, currentLocation); }, - ["sysml:CrossSubsetting"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:CrossSubsetting"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var crossSubsettingReader = new CrossSubsettingReader(cache, this, externalReferenceService, loggerFactory); + var crossSubsettingReader = new CrossSubsettingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return crossSubsettingReader.Read(subXmlReader, currentLocation); }, - ["sysml:DataType"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:DataType"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var dataTypeReader = new DataTypeReader(cache, this, externalReferenceService, loggerFactory); + var dataTypeReader = new DataTypeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return dataTypeReader.Read(subXmlReader, currentLocation); }, - ["sysml:DecisionNode"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:DecisionNode"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var decisionNodeReader = new DecisionNodeReader(cache, this, externalReferenceService, loggerFactory); + var decisionNodeReader = new DecisionNodeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return decisionNodeReader.Read(subXmlReader, currentLocation); }, - ["sysml:Definition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Definition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var definitionReader = new DefinitionReader(cache, this, externalReferenceService, loggerFactory); + var definitionReader = new DefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return definitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:Dependency"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Dependency"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var dependencyReader = new DependencyReader(cache, this, externalReferenceService, loggerFactory); + var dependencyReader = new DependencyReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return dependencyReader.Read(subXmlReader, currentLocation); }, - ["sysml:Differencing"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Differencing"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var differencingReader = new DifferencingReader(cache, this, externalReferenceService, loggerFactory); + var differencingReader = new DifferencingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return differencingReader.Read(subXmlReader, currentLocation); }, - ["sysml:Disjoining"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Disjoining"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var disjoiningReader = new DisjoiningReader(cache, this, externalReferenceService, loggerFactory); + var disjoiningReader = new DisjoiningReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return disjoiningReader.Read(subXmlReader, currentLocation); }, - ["sysml:Documentation"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Documentation"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var documentationReader = new DocumentationReader(cache, this, externalReferenceService, loggerFactory); + var documentationReader = new DocumentationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return documentationReader.Read(subXmlReader, currentLocation); }, - ["sysml:ElementFilterMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ElementFilterMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var elementFilterMembershipReader = new ElementFilterMembershipReader(cache, this, externalReferenceService, loggerFactory); + var elementFilterMembershipReader = new ElementFilterMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return elementFilterMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:EndFeatureMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:EndFeatureMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var endFeatureMembershipReader = new EndFeatureMembershipReader(cache, this, externalReferenceService, loggerFactory); + var endFeatureMembershipReader = new EndFeatureMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return endFeatureMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:EnumerationDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:EnumerationDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var enumerationDefinitionReader = new EnumerationDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var enumerationDefinitionReader = new EnumerationDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return enumerationDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:EnumerationUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:EnumerationUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var enumerationUsageReader = new EnumerationUsageReader(cache, this, externalReferenceService, loggerFactory); + var enumerationUsageReader = new EnumerationUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return enumerationUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:EventOccurrenceUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:EventOccurrenceUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var eventOccurrenceUsageReader = new EventOccurrenceUsageReader(cache, this, externalReferenceService, loggerFactory); + var eventOccurrenceUsageReader = new EventOccurrenceUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return eventOccurrenceUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:ExhibitStateUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ExhibitStateUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var exhibitStateUsageReader = new ExhibitStateUsageReader(cache, this, externalReferenceService, loggerFactory); + var exhibitStateUsageReader = new ExhibitStateUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return exhibitStateUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:Expression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Expression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var expressionReader = new ExpressionReader(cache, this, externalReferenceService, loggerFactory); + var expressionReader = new ExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return expressionReader.Read(subXmlReader, currentLocation); }, - ["sysml:Feature"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Feature"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureReader = new FeatureReader(cache, this, externalReferenceService, loggerFactory); + var featureReader = new FeatureReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return featureReader.Read(subXmlReader, currentLocation); }, - ["sysml:FeatureChainExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FeatureChainExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureChainExpressionReader = new FeatureChainExpressionReader(cache, this, externalReferenceService, loggerFactory); + var featureChainExpressionReader = new FeatureChainExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return featureChainExpressionReader.Read(subXmlReader, currentLocation); }, - ["sysml:FeatureChaining"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FeatureChaining"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureChainingReader = new FeatureChainingReader(cache, this, externalReferenceService, loggerFactory); + var featureChainingReader = new FeatureChainingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return featureChainingReader.Read(subXmlReader, currentLocation); }, - ["sysml:FeatureInverting"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FeatureInverting"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureInvertingReader = new FeatureInvertingReader(cache, this, externalReferenceService, loggerFactory); + var featureInvertingReader = new FeatureInvertingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return featureInvertingReader.Read(subXmlReader, currentLocation); }, - ["sysml:FeatureMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FeatureMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureMembershipReader = new FeatureMembershipReader(cache, this, externalReferenceService, loggerFactory); + var featureMembershipReader = new FeatureMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return featureMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:FeatureReferenceExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FeatureReferenceExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureReferenceExpressionReader = new FeatureReferenceExpressionReader(cache, this, externalReferenceService, loggerFactory); + var featureReferenceExpressionReader = new FeatureReferenceExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return featureReferenceExpressionReader.Read(subXmlReader, currentLocation); }, - ["sysml:FeatureTyping"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FeatureTyping"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureTypingReader = new FeatureTypingReader(cache, this, externalReferenceService, loggerFactory); + var featureTypingReader = new FeatureTypingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return featureTypingReader.Read(subXmlReader, currentLocation); }, - ["sysml:FeatureValue"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FeatureValue"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureValueReader = new FeatureValueReader(cache, this, externalReferenceService, loggerFactory); + var featureValueReader = new FeatureValueReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return featureValueReader.Read(subXmlReader, currentLocation); }, - ["sysml:Flow"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Flow"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var flowReader = new FlowReader(cache, this, externalReferenceService, loggerFactory); + var flowReader = new FlowReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return flowReader.Read(subXmlReader, currentLocation); }, - ["sysml:FlowDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FlowDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var flowDefinitionReader = new FlowDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var flowDefinitionReader = new FlowDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return flowDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:FlowEnd"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FlowEnd"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var flowEndReader = new FlowEndReader(cache, this, externalReferenceService, loggerFactory); + var flowEndReader = new FlowEndReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return flowEndReader.Read(subXmlReader, currentLocation); }, - ["sysml:FlowUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FlowUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var flowUsageReader = new FlowUsageReader(cache, this, externalReferenceService, loggerFactory); + var flowUsageReader = new FlowUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return flowUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:ForkNode"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ForkNode"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var forkNodeReader = new ForkNodeReader(cache, this, externalReferenceService, loggerFactory); + var forkNodeReader = new ForkNodeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return forkNodeReader.Read(subXmlReader, currentLocation); }, - ["sysml:ForLoopActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ForLoopActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var forLoopActionUsageReader = new ForLoopActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var forLoopActionUsageReader = new ForLoopActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return forLoopActionUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:FramedConcernMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FramedConcernMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var framedConcernMembershipReader = new FramedConcernMembershipReader(cache, this, externalReferenceService, loggerFactory); + var framedConcernMembershipReader = new FramedConcernMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return framedConcernMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:Function"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Function"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var functionReader = new FunctionReader(cache, this, externalReferenceService, loggerFactory); + var functionReader = new FunctionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return functionReader.Read(subXmlReader, currentLocation); }, - ["sysml:IfActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:IfActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var ifActionUsageReader = new IfActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var ifActionUsageReader = new IfActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return ifActionUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:IncludeUseCaseUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:IncludeUseCaseUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var includeUseCaseUsageReader = new IncludeUseCaseUsageReader(cache, this, externalReferenceService, loggerFactory); + var includeUseCaseUsageReader = new IncludeUseCaseUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return includeUseCaseUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:IndexExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:IndexExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var indexExpressionReader = new IndexExpressionReader(cache, this, externalReferenceService, loggerFactory); + var indexExpressionReader = new IndexExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return indexExpressionReader.Read(subXmlReader, currentLocation); }, - ["sysml:Interaction"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Interaction"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var interactionReader = new InteractionReader(cache, this, externalReferenceService, loggerFactory); + var interactionReader = new InteractionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return interactionReader.Read(subXmlReader, currentLocation); }, - ["sysml:InterfaceDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:InterfaceDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var interfaceDefinitionReader = new InterfaceDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var interfaceDefinitionReader = new InterfaceDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return interfaceDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:InterfaceUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:InterfaceUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var interfaceUsageReader = new InterfaceUsageReader(cache, this, externalReferenceService, loggerFactory); + var interfaceUsageReader = new InterfaceUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return interfaceUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:Intersecting"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Intersecting"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var intersectingReader = new IntersectingReader(cache, this, externalReferenceService, loggerFactory); + var intersectingReader = new IntersectingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return intersectingReader.Read(subXmlReader, currentLocation); }, - ["sysml:Invariant"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Invariant"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var invariantReader = new InvariantReader(cache, this, externalReferenceService, loggerFactory); + var invariantReader = new InvariantReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return invariantReader.Read(subXmlReader, currentLocation); }, - ["sysml:InvocationExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:InvocationExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var invocationExpressionReader = new InvocationExpressionReader(cache, this, externalReferenceService, loggerFactory); + var invocationExpressionReader = new InvocationExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return invocationExpressionReader.Read(subXmlReader, currentLocation); }, - ["sysml:ItemDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ItemDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var itemDefinitionReader = new ItemDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var itemDefinitionReader = new ItemDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return itemDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:ItemUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ItemUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var itemUsageReader = new ItemUsageReader(cache, this, externalReferenceService, loggerFactory); + var itemUsageReader = new ItemUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return itemUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:JoinNode"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:JoinNode"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var joinNodeReader = new JoinNodeReader(cache, this, externalReferenceService, loggerFactory); + var joinNodeReader = new JoinNodeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return joinNodeReader.Read(subXmlReader, currentLocation); }, - ["sysml:LibraryPackage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:LibraryPackage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var libraryPackageReader = new LibraryPackageReader(cache, this, externalReferenceService, loggerFactory); + var libraryPackageReader = new LibraryPackageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return libraryPackageReader.Read(subXmlReader, currentLocation); }, - ["sysml:LiteralBoolean"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:LiteralBoolean"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var literalBooleanReader = new LiteralBooleanReader(cache, this, externalReferenceService, loggerFactory); + var literalBooleanReader = new LiteralBooleanReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return literalBooleanReader.Read(subXmlReader, currentLocation); }, - ["sysml:LiteralExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:LiteralExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var literalExpressionReader = new LiteralExpressionReader(cache, this, externalReferenceService, loggerFactory); + var literalExpressionReader = new LiteralExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return literalExpressionReader.Read(subXmlReader, currentLocation); }, - ["sysml:LiteralInfinity"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:LiteralInfinity"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var literalInfinityReader = new LiteralInfinityReader(cache, this, externalReferenceService, loggerFactory); + var literalInfinityReader = new LiteralInfinityReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return literalInfinityReader.Read(subXmlReader, currentLocation); }, - ["sysml:LiteralInteger"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:LiteralInteger"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var literalIntegerReader = new LiteralIntegerReader(cache, this, externalReferenceService, loggerFactory); + var literalIntegerReader = new LiteralIntegerReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return literalIntegerReader.Read(subXmlReader, currentLocation); }, - ["sysml:LiteralRational"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:LiteralRational"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var literalRationalReader = new LiteralRationalReader(cache, this, externalReferenceService, loggerFactory); + var literalRationalReader = new LiteralRationalReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return literalRationalReader.Read(subXmlReader, currentLocation); }, - ["sysml:LiteralString"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:LiteralString"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var literalStringReader = new LiteralStringReader(cache, this, externalReferenceService, loggerFactory); + var literalStringReader = new LiteralStringReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return literalStringReader.Read(subXmlReader, currentLocation); }, - ["sysml:Membership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Membership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var membershipReader = new MembershipReader(cache, this, externalReferenceService, loggerFactory); + var membershipReader = new MembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return membershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:MembershipExpose"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MembershipExpose"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var membershipExposeReader = new MembershipExposeReader(cache, this, externalReferenceService, loggerFactory); + var membershipExposeReader = new MembershipExposeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return membershipExposeReader.Read(subXmlReader, currentLocation); }, - ["sysml:MembershipImport"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MembershipImport"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var membershipImportReader = new MembershipImportReader(cache, this, externalReferenceService, loggerFactory); + var membershipImportReader = new MembershipImportReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return membershipImportReader.Read(subXmlReader, currentLocation); }, - ["sysml:MergeNode"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MergeNode"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var mergeNodeReader = new MergeNodeReader(cache, this, externalReferenceService, loggerFactory); + var mergeNodeReader = new MergeNodeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return mergeNodeReader.Read(subXmlReader, currentLocation); }, - ["sysml:Metaclass"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Metaclass"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var metaclassReader = new MetaclassReader(cache, this, externalReferenceService, loggerFactory); + var metaclassReader = new MetaclassReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return metaclassReader.Read(subXmlReader, currentLocation); }, - ["sysml:MetadataAccessExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MetadataAccessExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var metadataAccessExpressionReader = new MetadataAccessExpressionReader(cache, this, externalReferenceService, loggerFactory); + var metadataAccessExpressionReader = new MetadataAccessExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return metadataAccessExpressionReader.Read(subXmlReader, currentLocation); }, - ["sysml:MetadataDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MetadataDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var metadataDefinitionReader = new MetadataDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var metadataDefinitionReader = new MetadataDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return metadataDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:MetadataFeature"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MetadataFeature"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var metadataFeatureReader = new MetadataFeatureReader(cache, this, externalReferenceService, loggerFactory); + var metadataFeatureReader = new MetadataFeatureReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return metadataFeatureReader.Read(subXmlReader, currentLocation); }, - ["sysml:MetadataUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MetadataUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var metadataUsageReader = new MetadataUsageReader(cache, this, externalReferenceService, loggerFactory); + var metadataUsageReader = new MetadataUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return metadataUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:Multiplicity"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Multiplicity"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var multiplicityReader = new MultiplicityReader(cache, this, externalReferenceService, loggerFactory); + var multiplicityReader = new MultiplicityReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return multiplicityReader.Read(subXmlReader, currentLocation); }, - ["sysml:MultiplicityRange"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MultiplicityRange"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var multiplicityRangeReader = new MultiplicityRangeReader(cache, this, externalReferenceService, loggerFactory); + var multiplicityRangeReader = new MultiplicityRangeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return multiplicityRangeReader.Read(subXmlReader, currentLocation); }, - ["sysml:Namespace"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Namespace"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var namespaceReader = new NamespaceReader(cache, this, externalReferenceService, loggerFactory); + var namespaceReader = new NamespaceReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return namespaceReader.Read(subXmlReader, currentLocation); }, - ["sysml:NamespaceExpose"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:NamespaceExpose"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var namespaceExposeReader = new NamespaceExposeReader(cache, this, externalReferenceService, loggerFactory); + var namespaceExposeReader = new NamespaceExposeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return namespaceExposeReader.Read(subXmlReader, currentLocation); }, - ["sysml:NamespaceImport"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:NamespaceImport"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var namespaceImportReader = new NamespaceImportReader(cache, this, externalReferenceService, loggerFactory); + var namespaceImportReader = new NamespaceImportReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return namespaceImportReader.Read(subXmlReader, currentLocation); }, - ["sysml:NullExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:NullExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var nullExpressionReader = new NullExpressionReader(cache, this, externalReferenceService, loggerFactory); + var nullExpressionReader = new NullExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return nullExpressionReader.Read(subXmlReader, currentLocation); }, - ["sysml:ObjectiveMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ObjectiveMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var objectiveMembershipReader = new ObjectiveMembershipReader(cache, this, externalReferenceService, loggerFactory); + var objectiveMembershipReader = new ObjectiveMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return objectiveMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:OccurrenceDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:OccurrenceDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var occurrenceDefinitionReader = new OccurrenceDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var occurrenceDefinitionReader = new OccurrenceDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return occurrenceDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:OccurrenceUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:OccurrenceUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var occurrenceUsageReader = new OccurrenceUsageReader(cache, this, externalReferenceService, loggerFactory); + var occurrenceUsageReader = new OccurrenceUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return occurrenceUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:OperatorExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:OperatorExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var operatorExpressionReader = new OperatorExpressionReader(cache, this, externalReferenceService, loggerFactory); + var operatorExpressionReader = new OperatorExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return operatorExpressionReader.Read(subXmlReader, currentLocation); }, - ["sysml:OwningMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:OwningMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var owningMembershipReader = new OwningMembershipReader(cache, this, externalReferenceService, loggerFactory); + var owningMembershipReader = new OwningMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return owningMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:Package"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Package"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var packageReader = new PackageReader(cache, this, externalReferenceService, loggerFactory); + var packageReader = new PackageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return packageReader.Read(subXmlReader, currentLocation); }, - ["sysml:ParameterMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ParameterMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var parameterMembershipReader = new ParameterMembershipReader(cache, this, externalReferenceService, loggerFactory); + var parameterMembershipReader = new ParameterMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return parameterMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:PartDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:PartDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var partDefinitionReader = new PartDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var partDefinitionReader = new PartDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return partDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:PartUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:PartUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var partUsageReader = new PartUsageReader(cache, this, externalReferenceService, loggerFactory); + var partUsageReader = new PartUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return partUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:PayloadFeature"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:PayloadFeature"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var payloadFeatureReader = new PayloadFeatureReader(cache, this, externalReferenceService, loggerFactory); + var payloadFeatureReader = new PayloadFeatureReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return payloadFeatureReader.Read(subXmlReader, currentLocation); }, - ["sysml:PerformActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:PerformActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var performActionUsageReader = new PerformActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var performActionUsageReader = new PerformActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return performActionUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:PortConjugation"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:PortConjugation"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var portConjugationReader = new PortConjugationReader(cache, this, externalReferenceService, loggerFactory); + var portConjugationReader = new PortConjugationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return portConjugationReader.Read(subXmlReader, currentLocation); }, - ["sysml:PortDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:PortDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var portDefinitionReader = new PortDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var portDefinitionReader = new PortDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return portDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:PortUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:PortUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var portUsageReader = new PortUsageReader(cache, this, externalReferenceService, loggerFactory); + var portUsageReader = new PortUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return portUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:Predicate"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Predicate"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var predicateReader = new PredicateReader(cache, this, externalReferenceService, loggerFactory); + var predicateReader = new PredicateReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return predicateReader.Read(subXmlReader, currentLocation); }, - ["sysml:Redefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Redefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var redefinitionReader = new RedefinitionReader(cache, this, externalReferenceService, loggerFactory); + var redefinitionReader = new RedefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return redefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:ReferenceSubsetting"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ReferenceSubsetting"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var referenceSubsettingReader = new ReferenceSubsettingReader(cache, this, externalReferenceService, loggerFactory); + var referenceSubsettingReader = new ReferenceSubsettingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return referenceSubsettingReader.Read(subXmlReader, currentLocation); }, - ["sysml:ReferenceUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ReferenceUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var referenceUsageReader = new ReferenceUsageReader(cache, this, externalReferenceService, loggerFactory); + var referenceUsageReader = new ReferenceUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return referenceUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:RenderingDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:RenderingDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var renderingDefinitionReader = new RenderingDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var renderingDefinitionReader = new RenderingDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return renderingDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:RenderingUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:RenderingUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var renderingUsageReader = new RenderingUsageReader(cache, this, externalReferenceService, loggerFactory); + var renderingUsageReader = new RenderingUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return renderingUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:RequirementConstraintMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:RequirementConstraintMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var requirementConstraintMembershipReader = new RequirementConstraintMembershipReader(cache, this, externalReferenceService, loggerFactory); + var requirementConstraintMembershipReader = new RequirementConstraintMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return requirementConstraintMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:RequirementDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:RequirementDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var requirementDefinitionReader = new RequirementDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var requirementDefinitionReader = new RequirementDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return requirementDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:RequirementUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:RequirementUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var requirementUsageReader = new RequirementUsageReader(cache, this, externalReferenceService, loggerFactory); + var requirementUsageReader = new RequirementUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return requirementUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:RequirementVerificationMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:RequirementVerificationMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var requirementVerificationMembershipReader = new RequirementVerificationMembershipReader(cache, this, externalReferenceService, loggerFactory); + var requirementVerificationMembershipReader = new RequirementVerificationMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return requirementVerificationMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:ResultExpressionMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ResultExpressionMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var resultExpressionMembershipReader = new ResultExpressionMembershipReader(cache, this, externalReferenceService, loggerFactory); + var resultExpressionMembershipReader = new ResultExpressionMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return resultExpressionMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:ReturnParameterMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ReturnParameterMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var returnParameterMembershipReader = new ReturnParameterMembershipReader(cache, this, externalReferenceService, loggerFactory); + var returnParameterMembershipReader = new ReturnParameterMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return returnParameterMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:SatisfyRequirementUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:SatisfyRequirementUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var satisfyRequirementUsageReader = new SatisfyRequirementUsageReader(cache, this, externalReferenceService, loggerFactory); + var satisfyRequirementUsageReader = new SatisfyRequirementUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return satisfyRequirementUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:SelectExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:SelectExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var selectExpressionReader = new SelectExpressionReader(cache, this, externalReferenceService, loggerFactory); + var selectExpressionReader = new SelectExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return selectExpressionReader.Read(subXmlReader, currentLocation); }, - ["sysml:SendActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:SendActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var sendActionUsageReader = new SendActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var sendActionUsageReader = new SendActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return sendActionUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:Specialization"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Specialization"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var specializationReader = new SpecializationReader(cache, this, externalReferenceService, loggerFactory); + var specializationReader = new SpecializationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return specializationReader.Read(subXmlReader, currentLocation); }, - ["sysml:StakeholderMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:StakeholderMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var stakeholderMembershipReader = new StakeholderMembershipReader(cache, this, externalReferenceService, loggerFactory); + var stakeholderMembershipReader = new StakeholderMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return stakeholderMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:StateDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:StateDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var stateDefinitionReader = new StateDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var stateDefinitionReader = new StateDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return stateDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:StateSubactionMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:StateSubactionMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var stateSubactionMembershipReader = new StateSubactionMembershipReader(cache, this, externalReferenceService, loggerFactory); + var stateSubactionMembershipReader = new StateSubactionMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return stateSubactionMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:StateUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:StateUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var stateUsageReader = new StateUsageReader(cache, this, externalReferenceService, loggerFactory); + var stateUsageReader = new StateUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return stateUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:Step"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Step"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var stepReader = new StepReader(cache, this, externalReferenceService, loggerFactory); + var stepReader = new StepReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return stepReader.Read(subXmlReader, currentLocation); }, - ["sysml:Structure"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Structure"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var structureReader = new StructureReader(cache, this, externalReferenceService, loggerFactory); + var structureReader = new StructureReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return structureReader.Read(subXmlReader, currentLocation); }, - ["sysml:Subclassification"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Subclassification"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var subclassificationReader = new SubclassificationReader(cache, this, externalReferenceService, loggerFactory); + var subclassificationReader = new SubclassificationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return subclassificationReader.Read(subXmlReader, currentLocation); }, - ["sysml:SubjectMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:SubjectMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var subjectMembershipReader = new SubjectMembershipReader(cache, this, externalReferenceService, loggerFactory); + var subjectMembershipReader = new SubjectMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return subjectMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:Subsetting"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Subsetting"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var subsettingReader = new SubsettingReader(cache, this, externalReferenceService, loggerFactory); + var subsettingReader = new SubsettingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return subsettingReader.Read(subXmlReader, currentLocation); }, - ["sysml:Succession"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Succession"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var successionReader = new SuccessionReader(cache, this, externalReferenceService, loggerFactory); + var successionReader = new SuccessionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return successionReader.Read(subXmlReader, currentLocation); }, - ["sysml:SuccessionAsUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:SuccessionAsUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var successionAsUsageReader = new SuccessionAsUsageReader(cache, this, externalReferenceService, loggerFactory); + var successionAsUsageReader = new SuccessionAsUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return successionAsUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:SuccessionFlow"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:SuccessionFlow"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var successionFlowReader = new SuccessionFlowReader(cache, this, externalReferenceService, loggerFactory); + var successionFlowReader = new SuccessionFlowReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return successionFlowReader.Read(subXmlReader, currentLocation); }, - ["sysml:SuccessionFlowUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:SuccessionFlowUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var successionFlowUsageReader = new SuccessionFlowUsageReader(cache, this, externalReferenceService, loggerFactory); + var successionFlowUsageReader = new SuccessionFlowUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return successionFlowUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:TerminateActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:TerminateActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var terminateActionUsageReader = new TerminateActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var terminateActionUsageReader = new TerminateActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return terminateActionUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:TextualRepresentation"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:TextualRepresentation"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var textualRepresentationReader = new TextualRepresentationReader(cache, this, externalReferenceService, loggerFactory); + var textualRepresentationReader = new TextualRepresentationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return textualRepresentationReader.Read(subXmlReader, currentLocation); }, - ["sysml:TransitionFeatureMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:TransitionFeatureMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var transitionFeatureMembershipReader = new TransitionFeatureMembershipReader(cache, this, externalReferenceService, loggerFactory); + var transitionFeatureMembershipReader = new TransitionFeatureMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return transitionFeatureMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:TransitionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:TransitionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var transitionUsageReader = new TransitionUsageReader(cache, this, externalReferenceService, loggerFactory); + var transitionUsageReader = new TransitionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return transitionUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:TriggerInvocationExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:TriggerInvocationExpression"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var triggerInvocationExpressionReader = new TriggerInvocationExpressionReader(cache, this, externalReferenceService, loggerFactory); + var triggerInvocationExpressionReader = new TriggerInvocationExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return triggerInvocationExpressionReader.Read(subXmlReader, currentLocation); }, - ["sysml:Type"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Type"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var typeReader = new TypeReader(cache, this, externalReferenceService, loggerFactory); + var typeReader = new TypeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return typeReader.Read(subXmlReader, currentLocation); }, - ["sysml:TypeFeaturing"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:TypeFeaturing"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var typeFeaturingReader = new TypeFeaturingReader(cache, this, externalReferenceService, loggerFactory); + var typeFeaturingReader = new TypeFeaturingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return typeFeaturingReader.Read(subXmlReader, currentLocation); }, - ["sysml:Unioning"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Unioning"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var unioningReader = new UnioningReader(cache, this, externalReferenceService, loggerFactory); + var unioningReader = new UnioningReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return unioningReader.Read(subXmlReader, currentLocation); }, - ["sysml:Usage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Usage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var usageReader = new UsageReader(cache, this, externalReferenceService, loggerFactory); + var usageReader = new UsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return usageReader.Read(subXmlReader, currentLocation); }, - ["sysml:UseCaseDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:UseCaseDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var useCaseDefinitionReader = new UseCaseDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var useCaseDefinitionReader = new UseCaseDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return useCaseDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:UseCaseUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:UseCaseUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var useCaseUsageReader = new UseCaseUsageReader(cache, this, externalReferenceService, loggerFactory); + var useCaseUsageReader = new UseCaseUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return useCaseUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:VariantMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:VariantMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var variantMembershipReader = new VariantMembershipReader(cache, this, externalReferenceService, loggerFactory); + var variantMembershipReader = new VariantMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return variantMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:VerificationCaseDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:VerificationCaseDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var verificationCaseDefinitionReader = new VerificationCaseDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var verificationCaseDefinitionReader = new VerificationCaseDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return verificationCaseDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:VerificationCaseUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:VerificationCaseUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var verificationCaseUsageReader = new VerificationCaseUsageReader(cache, this, externalReferenceService, loggerFactory); + var verificationCaseUsageReader = new VerificationCaseUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return verificationCaseUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:ViewDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ViewDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var viewDefinitionReader = new ViewDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var viewDefinitionReader = new ViewDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return viewDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:ViewpointDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ViewpointDefinition"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var viewpointDefinitionReader = new ViewpointDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var viewpointDefinitionReader = new ViewpointDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return viewpointDefinitionReader.Read(subXmlReader, currentLocation); }, - ["sysml:ViewpointUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ViewpointUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var viewpointUsageReader = new ViewpointUsageReader(cache, this, externalReferenceService, loggerFactory); + var viewpointUsageReader = new ViewpointUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return viewpointUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:ViewRenderingMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ViewRenderingMembership"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var viewRenderingMembershipReader = new ViewRenderingMembershipReader(cache, this, externalReferenceService, loggerFactory); + var viewRenderingMembershipReader = new ViewRenderingMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return viewRenderingMembershipReader.Read(subXmlReader, currentLocation); }, - ["sysml:ViewUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ViewUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var viewUsageReader = new ViewUsageReader(cache, this, externalReferenceService, loggerFactory); + var viewUsageReader = new ViewUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return viewUsageReader.Read(subXmlReader, currentLocation); }, - ["sysml:WhileLoopActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:WhileLoopActionUsage"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var whileLoopActionUsageReader = new WhileLoopActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var whileLoopActionUsageReader = new WhileLoopActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return whileLoopActionUsageReader.Read(subXmlReader, currentLocation); }, }; - this.readerAsyncCache = new Dictionary>> + this.readerAsyncCache = new Dictionary>> { - ["sysml:AcceptActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AcceptActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var acceptActionUsageReader = new AcceptActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var acceptActionUsageReader = new AcceptActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await acceptActionUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ActionDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ActionDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var actionDefinitionReader = new ActionDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var actionDefinitionReader = new ActionDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await actionDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var actionUsageReader = new ActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var actionUsageReader = new ActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await actionUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ActorMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ActorMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var actorMembershipReader = new ActorMembershipReader(cache, this, externalReferenceService, loggerFactory); + var actorMembershipReader = new ActorMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await actorMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:AllocationDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AllocationDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var allocationDefinitionReader = new AllocationDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var allocationDefinitionReader = new AllocationDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await allocationDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:AllocationUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AllocationUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var allocationUsageReader = new AllocationUsageReader(cache, this, externalReferenceService, loggerFactory); + var allocationUsageReader = new AllocationUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await allocationUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:AnalysisCaseDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AnalysisCaseDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var analysisCaseDefinitionReader = new AnalysisCaseDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var analysisCaseDefinitionReader = new AnalysisCaseDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await analysisCaseDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:AnalysisCaseUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AnalysisCaseUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var analysisCaseUsageReader = new AnalysisCaseUsageReader(cache, this, externalReferenceService, loggerFactory); + var analysisCaseUsageReader = new AnalysisCaseUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await analysisCaseUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:AnnotatingElement"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AnnotatingElement"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var annotatingElementReader = new AnnotatingElementReader(cache, this, externalReferenceService, loggerFactory); + var annotatingElementReader = new AnnotatingElementReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await annotatingElementReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Annotation"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Annotation"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var annotationReader = new AnnotationReader(cache, this, externalReferenceService, loggerFactory); + var annotationReader = new AnnotationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await annotationReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:AssertConstraintUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AssertConstraintUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var assertConstraintUsageReader = new AssertConstraintUsageReader(cache, this, externalReferenceService, loggerFactory); + var assertConstraintUsageReader = new AssertConstraintUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await assertConstraintUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:AssignmentActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AssignmentActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var assignmentActionUsageReader = new AssignmentActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var assignmentActionUsageReader = new AssignmentActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await assignmentActionUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Association"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Association"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var associationReader = new AssociationReader(cache, this, externalReferenceService, loggerFactory); + var associationReader = new AssociationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await associationReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:AssociationStructure"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AssociationStructure"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var associationStructureReader = new AssociationStructureReader(cache, this, externalReferenceService, loggerFactory); + var associationStructureReader = new AssociationStructureReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await associationStructureReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:AttributeDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AttributeDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var attributeDefinitionReader = new AttributeDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var attributeDefinitionReader = new AttributeDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await attributeDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:AttributeUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:AttributeUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var attributeUsageReader = new AttributeUsageReader(cache, this, externalReferenceService, loggerFactory); + var attributeUsageReader = new AttributeUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await attributeUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Behavior"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Behavior"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var behaviorReader = new BehaviorReader(cache, this, externalReferenceService, loggerFactory); + var behaviorReader = new BehaviorReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await behaviorReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:BindingConnector"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:BindingConnector"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var bindingConnectorReader = new BindingConnectorReader(cache, this, externalReferenceService, loggerFactory); + var bindingConnectorReader = new BindingConnectorReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await bindingConnectorReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:BindingConnectorAsUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:BindingConnectorAsUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var bindingConnectorAsUsageReader = new BindingConnectorAsUsageReader(cache, this, externalReferenceService, loggerFactory); + var bindingConnectorAsUsageReader = new BindingConnectorAsUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await bindingConnectorAsUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:BooleanExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:BooleanExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var booleanExpressionReader = new BooleanExpressionReader(cache, this, externalReferenceService, loggerFactory); + var booleanExpressionReader = new BooleanExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await booleanExpressionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:CalculationDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:CalculationDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var calculationDefinitionReader = new CalculationDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var calculationDefinitionReader = new CalculationDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await calculationDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:CalculationUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:CalculationUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var calculationUsageReader = new CalculationUsageReader(cache, this, externalReferenceService, loggerFactory); + var calculationUsageReader = new CalculationUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await calculationUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:CaseDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:CaseDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var caseDefinitionReader = new CaseDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var caseDefinitionReader = new CaseDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await caseDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:CaseUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:CaseUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var caseUsageReader = new CaseUsageReader(cache, this, externalReferenceService, loggerFactory); + var caseUsageReader = new CaseUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await caseUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Class"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Class"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var classReader = new ClassReader(cache, this, externalReferenceService, loggerFactory); + var classReader = new ClassReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await classReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Classifier"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Classifier"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var classifierReader = new ClassifierReader(cache, this, externalReferenceService, loggerFactory); + var classifierReader = new ClassifierReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await classifierReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:CollectExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:CollectExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var collectExpressionReader = new CollectExpressionReader(cache, this, externalReferenceService, loggerFactory); + var collectExpressionReader = new CollectExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await collectExpressionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Comment"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Comment"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var commentReader = new CommentReader(cache, this, externalReferenceService, loggerFactory); + var commentReader = new CommentReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await commentReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ConcernDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConcernDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var concernDefinitionReader = new ConcernDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var concernDefinitionReader = new ConcernDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await concernDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ConcernUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConcernUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var concernUsageReader = new ConcernUsageReader(cache, this, externalReferenceService, loggerFactory); + var concernUsageReader = new ConcernUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await concernUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ConjugatedPortDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConjugatedPortDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var conjugatedPortDefinitionReader = new ConjugatedPortDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var conjugatedPortDefinitionReader = new ConjugatedPortDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await conjugatedPortDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ConjugatedPortTyping"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConjugatedPortTyping"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var conjugatedPortTypingReader = new ConjugatedPortTypingReader(cache, this, externalReferenceService, loggerFactory); + var conjugatedPortTypingReader = new ConjugatedPortTypingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await conjugatedPortTypingReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Conjugation"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Conjugation"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var conjugationReader = new ConjugationReader(cache, this, externalReferenceService, loggerFactory); + var conjugationReader = new ConjugationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await conjugationReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ConnectionDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConnectionDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var connectionDefinitionReader = new ConnectionDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var connectionDefinitionReader = new ConnectionDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await connectionDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ConnectionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConnectionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var connectionUsageReader = new ConnectionUsageReader(cache, this, externalReferenceService, loggerFactory); + var connectionUsageReader = new ConnectionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await connectionUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Connector"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Connector"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var connectorReader = new ConnectorReader(cache, this, externalReferenceService, loggerFactory); + var connectorReader = new ConnectorReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await connectorReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ConstraintDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConstraintDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var constraintDefinitionReader = new ConstraintDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var constraintDefinitionReader = new ConstraintDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await constraintDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ConstraintUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConstraintUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var constraintUsageReader = new ConstraintUsageReader(cache, this, externalReferenceService, loggerFactory); + var constraintUsageReader = new ConstraintUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await constraintUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ConstructorExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ConstructorExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var constructorExpressionReader = new ConstructorExpressionReader(cache, this, externalReferenceService, loggerFactory); + var constructorExpressionReader = new ConstructorExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await constructorExpressionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:CrossSubsetting"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:CrossSubsetting"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var crossSubsettingReader = new CrossSubsettingReader(cache, this, externalReferenceService, loggerFactory); + var crossSubsettingReader = new CrossSubsettingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await crossSubsettingReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:DataType"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:DataType"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var dataTypeReader = new DataTypeReader(cache, this, externalReferenceService, loggerFactory); + var dataTypeReader = new DataTypeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await dataTypeReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:DecisionNode"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:DecisionNode"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var decisionNodeReader = new DecisionNodeReader(cache, this, externalReferenceService, loggerFactory); + var decisionNodeReader = new DecisionNodeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await decisionNodeReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Definition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Definition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var definitionReader = new DefinitionReader(cache, this, externalReferenceService, loggerFactory); + var definitionReader = new DefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await definitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Dependency"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Dependency"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var dependencyReader = new DependencyReader(cache, this, externalReferenceService, loggerFactory); + var dependencyReader = new DependencyReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await dependencyReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Differencing"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Differencing"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var differencingReader = new DifferencingReader(cache, this, externalReferenceService, loggerFactory); + var differencingReader = new DifferencingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await differencingReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Disjoining"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Disjoining"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var disjoiningReader = new DisjoiningReader(cache, this, externalReferenceService, loggerFactory); + var disjoiningReader = new DisjoiningReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await disjoiningReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Documentation"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Documentation"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var documentationReader = new DocumentationReader(cache, this, externalReferenceService, loggerFactory); + var documentationReader = new DocumentationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await documentationReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ElementFilterMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ElementFilterMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var elementFilterMembershipReader = new ElementFilterMembershipReader(cache, this, externalReferenceService, loggerFactory); + var elementFilterMembershipReader = new ElementFilterMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await elementFilterMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:EndFeatureMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:EndFeatureMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var endFeatureMembershipReader = new EndFeatureMembershipReader(cache, this, externalReferenceService, loggerFactory); + var endFeatureMembershipReader = new EndFeatureMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await endFeatureMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:EnumerationDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:EnumerationDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var enumerationDefinitionReader = new EnumerationDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var enumerationDefinitionReader = new EnumerationDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await enumerationDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:EnumerationUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:EnumerationUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var enumerationUsageReader = new EnumerationUsageReader(cache, this, externalReferenceService, loggerFactory); + var enumerationUsageReader = new EnumerationUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await enumerationUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:EventOccurrenceUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:EventOccurrenceUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var eventOccurrenceUsageReader = new EventOccurrenceUsageReader(cache, this, externalReferenceService, loggerFactory); + var eventOccurrenceUsageReader = new EventOccurrenceUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await eventOccurrenceUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ExhibitStateUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ExhibitStateUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var exhibitStateUsageReader = new ExhibitStateUsageReader(cache, this, externalReferenceService, loggerFactory); + var exhibitStateUsageReader = new ExhibitStateUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await exhibitStateUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Expression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Expression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var expressionReader = new ExpressionReader(cache, this, externalReferenceService, loggerFactory); + var expressionReader = new ExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await expressionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Feature"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Feature"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureReader = new FeatureReader(cache, this, externalReferenceService, loggerFactory); + var featureReader = new FeatureReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await featureReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:FeatureChainExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FeatureChainExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureChainExpressionReader = new FeatureChainExpressionReader(cache, this, externalReferenceService, loggerFactory); + var featureChainExpressionReader = new FeatureChainExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await featureChainExpressionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:FeatureChaining"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FeatureChaining"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureChainingReader = new FeatureChainingReader(cache, this, externalReferenceService, loggerFactory); + var featureChainingReader = new FeatureChainingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await featureChainingReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:FeatureInverting"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FeatureInverting"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureInvertingReader = new FeatureInvertingReader(cache, this, externalReferenceService, loggerFactory); + var featureInvertingReader = new FeatureInvertingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await featureInvertingReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:FeatureMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FeatureMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureMembershipReader = new FeatureMembershipReader(cache, this, externalReferenceService, loggerFactory); + var featureMembershipReader = new FeatureMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await featureMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:FeatureReferenceExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FeatureReferenceExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureReferenceExpressionReader = new FeatureReferenceExpressionReader(cache, this, externalReferenceService, loggerFactory); + var featureReferenceExpressionReader = new FeatureReferenceExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await featureReferenceExpressionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:FeatureTyping"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FeatureTyping"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureTypingReader = new FeatureTypingReader(cache, this, externalReferenceService, loggerFactory); + var featureTypingReader = new FeatureTypingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await featureTypingReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:FeatureValue"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FeatureValue"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var featureValueReader = new FeatureValueReader(cache, this, externalReferenceService, loggerFactory); + var featureValueReader = new FeatureValueReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await featureValueReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Flow"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Flow"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var flowReader = new FlowReader(cache, this, externalReferenceService, loggerFactory); + var flowReader = new FlowReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await flowReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:FlowDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FlowDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var flowDefinitionReader = new FlowDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var flowDefinitionReader = new FlowDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await flowDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:FlowEnd"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FlowEnd"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var flowEndReader = new FlowEndReader(cache, this, externalReferenceService, loggerFactory); + var flowEndReader = new FlowEndReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await flowEndReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:FlowUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FlowUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var flowUsageReader = new FlowUsageReader(cache, this, externalReferenceService, loggerFactory); + var flowUsageReader = new FlowUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await flowUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ForkNode"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ForkNode"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var forkNodeReader = new ForkNodeReader(cache, this, externalReferenceService, loggerFactory); + var forkNodeReader = new ForkNodeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await forkNodeReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ForLoopActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ForLoopActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var forLoopActionUsageReader = new ForLoopActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var forLoopActionUsageReader = new ForLoopActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await forLoopActionUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:FramedConcernMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:FramedConcernMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var framedConcernMembershipReader = new FramedConcernMembershipReader(cache, this, externalReferenceService, loggerFactory); + var framedConcernMembershipReader = new FramedConcernMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await framedConcernMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Function"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Function"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var functionReader = new FunctionReader(cache, this, externalReferenceService, loggerFactory); + var functionReader = new FunctionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await functionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:IfActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:IfActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var ifActionUsageReader = new IfActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var ifActionUsageReader = new IfActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await ifActionUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:IncludeUseCaseUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:IncludeUseCaseUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var includeUseCaseUsageReader = new IncludeUseCaseUsageReader(cache, this, externalReferenceService, loggerFactory); + var includeUseCaseUsageReader = new IncludeUseCaseUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await includeUseCaseUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:IndexExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:IndexExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var indexExpressionReader = new IndexExpressionReader(cache, this, externalReferenceService, loggerFactory); + var indexExpressionReader = new IndexExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await indexExpressionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Interaction"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Interaction"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var interactionReader = new InteractionReader(cache, this, externalReferenceService, loggerFactory); + var interactionReader = new InteractionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await interactionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:InterfaceDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:InterfaceDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var interfaceDefinitionReader = new InterfaceDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var interfaceDefinitionReader = new InterfaceDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await interfaceDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:InterfaceUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:InterfaceUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var interfaceUsageReader = new InterfaceUsageReader(cache, this, externalReferenceService, loggerFactory); + var interfaceUsageReader = new InterfaceUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await interfaceUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Intersecting"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Intersecting"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var intersectingReader = new IntersectingReader(cache, this, externalReferenceService, loggerFactory); + var intersectingReader = new IntersectingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await intersectingReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Invariant"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Invariant"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var invariantReader = new InvariantReader(cache, this, externalReferenceService, loggerFactory); + var invariantReader = new InvariantReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await invariantReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:InvocationExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:InvocationExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var invocationExpressionReader = new InvocationExpressionReader(cache, this, externalReferenceService, loggerFactory); + var invocationExpressionReader = new InvocationExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await invocationExpressionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ItemDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ItemDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var itemDefinitionReader = new ItemDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var itemDefinitionReader = new ItemDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await itemDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ItemUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ItemUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var itemUsageReader = new ItemUsageReader(cache, this, externalReferenceService, loggerFactory); + var itemUsageReader = new ItemUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await itemUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:JoinNode"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:JoinNode"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var joinNodeReader = new JoinNodeReader(cache, this, externalReferenceService, loggerFactory); + var joinNodeReader = new JoinNodeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await joinNodeReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:LibraryPackage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:LibraryPackage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var libraryPackageReader = new LibraryPackageReader(cache, this, externalReferenceService, loggerFactory); + var libraryPackageReader = new LibraryPackageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await libraryPackageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:LiteralBoolean"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:LiteralBoolean"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var literalBooleanReader = new LiteralBooleanReader(cache, this, externalReferenceService, loggerFactory); + var literalBooleanReader = new LiteralBooleanReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await literalBooleanReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:LiteralExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:LiteralExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var literalExpressionReader = new LiteralExpressionReader(cache, this, externalReferenceService, loggerFactory); + var literalExpressionReader = new LiteralExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await literalExpressionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:LiteralInfinity"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:LiteralInfinity"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var literalInfinityReader = new LiteralInfinityReader(cache, this, externalReferenceService, loggerFactory); + var literalInfinityReader = new LiteralInfinityReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await literalInfinityReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:LiteralInteger"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:LiteralInteger"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var literalIntegerReader = new LiteralIntegerReader(cache, this, externalReferenceService, loggerFactory); + var literalIntegerReader = new LiteralIntegerReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await literalIntegerReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:LiteralRational"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:LiteralRational"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var literalRationalReader = new LiteralRationalReader(cache, this, externalReferenceService, loggerFactory); + var literalRationalReader = new LiteralRationalReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await literalRationalReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:LiteralString"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:LiteralString"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var literalStringReader = new LiteralStringReader(cache, this, externalReferenceService, loggerFactory); + var literalStringReader = new LiteralStringReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await literalStringReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Membership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Membership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var membershipReader = new MembershipReader(cache, this, externalReferenceService, loggerFactory); + var membershipReader = new MembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await membershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:MembershipExpose"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MembershipExpose"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var membershipExposeReader = new MembershipExposeReader(cache, this, externalReferenceService, loggerFactory); + var membershipExposeReader = new MembershipExposeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await membershipExposeReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:MembershipImport"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MembershipImport"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var membershipImportReader = new MembershipImportReader(cache, this, externalReferenceService, loggerFactory); + var membershipImportReader = new MembershipImportReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await membershipImportReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:MergeNode"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MergeNode"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var mergeNodeReader = new MergeNodeReader(cache, this, externalReferenceService, loggerFactory); + var mergeNodeReader = new MergeNodeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await mergeNodeReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Metaclass"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Metaclass"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var metaclassReader = new MetaclassReader(cache, this, externalReferenceService, loggerFactory); + var metaclassReader = new MetaclassReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await metaclassReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:MetadataAccessExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MetadataAccessExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var metadataAccessExpressionReader = new MetadataAccessExpressionReader(cache, this, externalReferenceService, loggerFactory); + var metadataAccessExpressionReader = new MetadataAccessExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await metadataAccessExpressionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:MetadataDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MetadataDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var metadataDefinitionReader = new MetadataDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var metadataDefinitionReader = new MetadataDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await metadataDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:MetadataFeature"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MetadataFeature"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var metadataFeatureReader = new MetadataFeatureReader(cache, this, externalReferenceService, loggerFactory); + var metadataFeatureReader = new MetadataFeatureReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await metadataFeatureReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:MetadataUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MetadataUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var metadataUsageReader = new MetadataUsageReader(cache, this, externalReferenceService, loggerFactory); + var metadataUsageReader = new MetadataUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await metadataUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Multiplicity"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Multiplicity"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var multiplicityReader = new MultiplicityReader(cache, this, externalReferenceService, loggerFactory); + var multiplicityReader = new MultiplicityReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await multiplicityReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:MultiplicityRange"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:MultiplicityRange"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var multiplicityRangeReader = new MultiplicityRangeReader(cache, this, externalReferenceService, loggerFactory); + var multiplicityRangeReader = new MultiplicityRangeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await multiplicityRangeReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Namespace"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Namespace"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var namespaceReader = new NamespaceReader(cache, this, externalReferenceService, loggerFactory); + var namespaceReader = new NamespaceReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await namespaceReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:NamespaceExpose"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:NamespaceExpose"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var namespaceExposeReader = new NamespaceExposeReader(cache, this, externalReferenceService, loggerFactory); + var namespaceExposeReader = new NamespaceExposeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await namespaceExposeReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:NamespaceImport"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:NamespaceImport"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var namespaceImportReader = new NamespaceImportReader(cache, this, externalReferenceService, loggerFactory); + var namespaceImportReader = new NamespaceImportReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await namespaceImportReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:NullExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:NullExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var nullExpressionReader = new NullExpressionReader(cache, this, externalReferenceService, loggerFactory); + var nullExpressionReader = new NullExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await nullExpressionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ObjectiveMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ObjectiveMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var objectiveMembershipReader = new ObjectiveMembershipReader(cache, this, externalReferenceService, loggerFactory); + var objectiveMembershipReader = new ObjectiveMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await objectiveMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:OccurrenceDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:OccurrenceDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var occurrenceDefinitionReader = new OccurrenceDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var occurrenceDefinitionReader = new OccurrenceDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await occurrenceDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:OccurrenceUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:OccurrenceUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var occurrenceUsageReader = new OccurrenceUsageReader(cache, this, externalReferenceService, loggerFactory); + var occurrenceUsageReader = new OccurrenceUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await occurrenceUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:OperatorExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:OperatorExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var operatorExpressionReader = new OperatorExpressionReader(cache, this, externalReferenceService, loggerFactory); + var operatorExpressionReader = new OperatorExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await operatorExpressionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:OwningMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:OwningMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var owningMembershipReader = new OwningMembershipReader(cache, this, externalReferenceService, loggerFactory); + var owningMembershipReader = new OwningMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await owningMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Package"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Package"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var packageReader = new PackageReader(cache, this, externalReferenceService, loggerFactory); + var packageReader = new PackageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await packageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ParameterMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ParameterMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var parameterMembershipReader = new ParameterMembershipReader(cache, this, externalReferenceService, loggerFactory); + var parameterMembershipReader = new ParameterMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await parameterMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:PartDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:PartDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var partDefinitionReader = new PartDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var partDefinitionReader = new PartDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await partDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:PartUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:PartUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var partUsageReader = new PartUsageReader(cache, this, externalReferenceService, loggerFactory); + var partUsageReader = new PartUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await partUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:PayloadFeature"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:PayloadFeature"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var payloadFeatureReader = new PayloadFeatureReader(cache, this, externalReferenceService, loggerFactory); + var payloadFeatureReader = new PayloadFeatureReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await payloadFeatureReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:PerformActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:PerformActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var performActionUsageReader = new PerformActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var performActionUsageReader = new PerformActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await performActionUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:PortConjugation"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:PortConjugation"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var portConjugationReader = new PortConjugationReader(cache, this, externalReferenceService, loggerFactory); + var portConjugationReader = new PortConjugationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await portConjugationReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:PortDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:PortDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var portDefinitionReader = new PortDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var portDefinitionReader = new PortDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await portDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:PortUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:PortUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var portUsageReader = new PortUsageReader(cache, this, externalReferenceService, loggerFactory); + var portUsageReader = new PortUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await portUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Predicate"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Predicate"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var predicateReader = new PredicateReader(cache, this, externalReferenceService, loggerFactory); + var predicateReader = new PredicateReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await predicateReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Redefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Redefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var redefinitionReader = new RedefinitionReader(cache, this, externalReferenceService, loggerFactory); + var redefinitionReader = new RedefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await redefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ReferenceSubsetting"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ReferenceSubsetting"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var referenceSubsettingReader = new ReferenceSubsettingReader(cache, this, externalReferenceService, loggerFactory); + var referenceSubsettingReader = new ReferenceSubsettingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await referenceSubsettingReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ReferenceUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ReferenceUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var referenceUsageReader = new ReferenceUsageReader(cache, this, externalReferenceService, loggerFactory); + var referenceUsageReader = new ReferenceUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await referenceUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:RenderingDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:RenderingDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var renderingDefinitionReader = new RenderingDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var renderingDefinitionReader = new RenderingDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await renderingDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:RenderingUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:RenderingUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var renderingUsageReader = new RenderingUsageReader(cache, this, externalReferenceService, loggerFactory); + var renderingUsageReader = new RenderingUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await renderingUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:RequirementConstraintMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:RequirementConstraintMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var requirementConstraintMembershipReader = new RequirementConstraintMembershipReader(cache, this, externalReferenceService, loggerFactory); + var requirementConstraintMembershipReader = new RequirementConstraintMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await requirementConstraintMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:RequirementDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:RequirementDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var requirementDefinitionReader = new RequirementDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var requirementDefinitionReader = new RequirementDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await requirementDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:RequirementUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:RequirementUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var requirementUsageReader = new RequirementUsageReader(cache, this, externalReferenceService, loggerFactory); + var requirementUsageReader = new RequirementUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await requirementUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:RequirementVerificationMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:RequirementVerificationMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var requirementVerificationMembershipReader = new RequirementVerificationMembershipReader(cache, this, externalReferenceService, loggerFactory); + var requirementVerificationMembershipReader = new RequirementVerificationMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await requirementVerificationMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ResultExpressionMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ResultExpressionMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var resultExpressionMembershipReader = new ResultExpressionMembershipReader(cache, this, externalReferenceService, loggerFactory); + var resultExpressionMembershipReader = new ResultExpressionMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await resultExpressionMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ReturnParameterMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ReturnParameterMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var returnParameterMembershipReader = new ReturnParameterMembershipReader(cache, this, externalReferenceService, loggerFactory); + var returnParameterMembershipReader = new ReturnParameterMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await returnParameterMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:SatisfyRequirementUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:SatisfyRequirementUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var satisfyRequirementUsageReader = new SatisfyRequirementUsageReader(cache, this, externalReferenceService, loggerFactory); + var satisfyRequirementUsageReader = new SatisfyRequirementUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await satisfyRequirementUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:SelectExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:SelectExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var selectExpressionReader = new SelectExpressionReader(cache, this, externalReferenceService, loggerFactory); + var selectExpressionReader = new SelectExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await selectExpressionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:SendActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:SendActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var sendActionUsageReader = new SendActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var sendActionUsageReader = new SendActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await sendActionUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Specialization"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Specialization"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var specializationReader = new SpecializationReader(cache, this, externalReferenceService, loggerFactory); + var specializationReader = new SpecializationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await specializationReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:StakeholderMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:StakeholderMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var stakeholderMembershipReader = new StakeholderMembershipReader(cache, this, externalReferenceService, loggerFactory); + var stakeholderMembershipReader = new StakeholderMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await stakeholderMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:StateDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:StateDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var stateDefinitionReader = new StateDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var stateDefinitionReader = new StateDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await stateDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:StateSubactionMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:StateSubactionMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var stateSubactionMembershipReader = new StateSubactionMembershipReader(cache, this, externalReferenceService, loggerFactory); + var stateSubactionMembershipReader = new StateSubactionMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await stateSubactionMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:StateUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:StateUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var stateUsageReader = new StateUsageReader(cache, this, externalReferenceService, loggerFactory); + var stateUsageReader = new StateUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await stateUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Step"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Step"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var stepReader = new StepReader(cache, this, externalReferenceService, loggerFactory); + var stepReader = new StepReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await stepReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Structure"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Structure"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var structureReader = new StructureReader(cache, this, externalReferenceService, loggerFactory); + var structureReader = new StructureReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await structureReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Subclassification"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Subclassification"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var subclassificationReader = new SubclassificationReader(cache, this, externalReferenceService, loggerFactory); + var subclassificationReader = new SubclassificationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await subclassificationReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:SubjectMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:SubjectMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var subjectMembershipReader = new SubjectMembershipReader(cache, this, externalReferenceService, loggerFactory); + var subjectMembershipReader = new SubjectMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await subjectMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Subsetting"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Subsetting"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var subsettingReader = new SubsettingReader(cache, this, externalReferenceService, loggerFactory); + var subsettingReader = new SubsettingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await subsettingReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Succession"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Succession"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var successionReader = new SuccessionReader(cache, this, externalReferenceService, loggerFactory); + var successionReader = new SuccessionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await successionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:SuccessionAsUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:SuccessionAsUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var successionAsUsageReader = new SuccessionAsUsageReader(cache, this, externalReferenceService, loggerFactory); + var successionAsUsageReader = new SuccessionAsUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await successionAsUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:SuccessionFlow"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:SuccessionFlow"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var successionFlowReader = new SuccessionFlowReader(cache, this, externalReferenceService, loggerFactory); + var successionFlowReader = new SuccessionFlowReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await successionFlowReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:SuccessionFlowUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:SuccessionFlowUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var successionFlowUsageReader = new SuccessionFlowUsageReader(cache, this, externalReferenceService, loggerFactory); + var successionFlowUsageReader = new SuccessionFlowUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await successionFlowUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:TerminateActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:TerminateActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var terminateActionUsageReader = new TerminateActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var terminateActionUsageReader = new TerminateActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await terminateActionUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:TextualRepresentation"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:TextualRepresentation"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var textualRepresentationReader = new TextualRepresentationReader(cache, this, externalReferenceService, loggerFactory); + var textualRepresentationReader = new TextualRepresentationReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await textualRepresentationReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:TransitionFeatureMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:TransitionFeatureMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var transitionFeatureMembershipReader = new TransitionFeatureMembershipReader(cache, this, externalReferenceService, loggerFactory); + var transitionFeatureMembershipReader = new TransitionFeatureMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await transitionFeatureMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:TransitionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:TransitionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var transitionUsageReader = new TransitionUsageReader(cache, this, externalReferenceService, loggerFactory); + var transitionUsageReader = new TransitionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await transitionUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:TriggerInvocationExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:TriggerInvocationExpression"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var triggerInvocationExpressionReader = new TriggerInvocationExpressionReader(cache, this, externalReferenceService, loggerFactory); + var triggerInvocationExpressionReader = new TriggerInvocationExpressionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await triggerInvocationExpressionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Type"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Type"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var typeReader = new TypeReader(cache, this, externalReferenceService, loggerFactory); + var typeReader = new TypeReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await typeReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:TypeFeaturing"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:TypeFeaturing"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var typeFeaturingReader = new TypeFeaturingReader(cache, this, externalReferenceService, loggerFactory); + var typeFeaturingReader = new TypeFeaturingReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await typeFeaturingReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Unioning"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Unioning"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var unioningReader = new UnioningReader(cache, this, externalReferenceService, loggerFactory); + var unioningReader = new UnioningReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await unioningReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:Usage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:Usage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var usageReader = new UsageReader(cache, this, externalReferenceService, loggerFactory); + var usageReader = new UsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await usageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:UseCaseDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:UseCaseDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var useCaseDefinitionReader = new UseCaseDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var useCaseDefinitionReader = new UseCaseDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await useCaseDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:UseCaseUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:UseCaseUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var useCaseUsageReader = new UseCaseUsageReader(cache, this, externalReferenceService, loggerFactory); + var useCaseUsageReader = new UseCaseUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await useCaseUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:VariantMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:VariantMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var variantMembershipReader = new VariantMembershipReader(cache, this, externalReferenceService, loggerFactory); + var variantMembershipReader = new VariantMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await variantMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:VerificationCaseDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:VerificationCaseDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var verificationCaseDefinitionReader = new VerificationCaseDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var verificationCaseDefinitionReader = new VerificationCaseDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await verificationCaseDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:VerificationCaseUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:VerificationCaseUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var verificationCaseUsageReader = new VerificationCaseUsageReader(cache, this, externalReferenceService, loggerFactory); + var verificationCaseUsageReader = new VerificationCaseUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await verificationCaseUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ViewDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ViewDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var viewDefinitionReader = new ViewDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var viewDefinitionReader = new ViewDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await viewDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ViewpointDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ViewpointDefinition"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var viewpointDefinitionReader = new ViewpointDefinitionReader(cache, this, externalReferenceService, loggerFactory); + var viewpointDefinitionReader = new ViewpointDefinitionReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await viewpointDefinitionReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ViewpointUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ViewpointUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var viewpointUsageReader = new ViewpointUsageReader(cache, this, externalReferenceService, loggerFactory); + var viewpointUsageReader = new ViewpointUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await viewpointUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ViewRenderingMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ViewRenderingMembership"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var viewRenderingMembershipReader = new ViewRenderingMembershipReader(cache, this, externalReferenceService, loggerFactory); + var viewRenderingMembershipReader = new ViewRenderingMembershipReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await viewRenderingMembershipReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:ViewUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:ViewUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var viewUsageReader = new ViewUsageReader(cache, this, externalReferenceService, loggerFactory); + var viewUsageReader = new ViewUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await viewUsageReader.ReadAsync(subXmlReader, currentLocation); }, - ["sysml:WhileLoopActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) => + ["sysml:WhileLoopActionUsage"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap) => { using var subXmlReader = xmlReader.ReadSubtree(); - var whileLoopActionUsageReader = new WhileLoopActionUsageReader(cache, this, externalReferenceService, loggerFactory); + var whileLoopActionUsageReader = new WhileLoopActionUsageReader(cache, this, externalReferenceService, loggerFactory, elementOriginMap); return await whileLoopActionUsageReader.ReadAsync(subXmlReader, currentLocation); }, }; @@ -2083,7 +2083,7 @@ public XmiDataReaderFacade() /// The explicit type name to resolve, in case of un-specified xsi:type /// An instance of the read /// If the xsi:type is not supported - public IData QueryXmiData(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = "") + public IData QueryXmiData(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = "", IXmiElementOriginMap elementOriginMap = null) { AssertValidQueryXmiDataParameters(xmiReader, xmiDataCache, currentLocation); @@ -2098,7 +2098,7 @@ public IData QueryXmiData(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri c if (this.readerCache.TryGetValue(xsiType, out var readerFactory)) { - return readerFactory(xmiDataCache, externalReferenceService, loggerFactory, xmiReader, currentLocation); + return readerFactory(xmiDataCache, externalReferenceService, loggerFactory, xmiReader, currentLocation, elementOriginMap); } throw new InvalidOperationException($"No reader found for xsi:type - {xsiType}"); @@ -2117,7 +2117,7 @@ public IData QueryXmiData(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri c /// The explicit type name to resolve, in case of un-specified xsi:type /// An awaitable with the instance of the read /// If the xsi:type is not supported - public Task QueryXmiDataAsync(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = "") + public Task QueryXmiDataAsync(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = "", IXmiElementOriginMap elementOriginMap = null) { AssertValidQueryXmiDataParameters(xmiReader, xmiDataCache, currentLocation); @@ -2132,7 +2132,7 @@ public Task QueryXmiDataAsync(XmlReader xmiReader, IXmiDataCache xmiDataC if (this.readerAsyncCache.TryGetValue(xsiType, out var readerFactory)) { - return readerFactory(xmiDataCache, externalReferenceService, loggerFactory, xmiReader, currentLocation); + return readerFactory(xmiDataCache, externalReferenceService, loggerFactory, xmiReader, currentLocation, elementOriginMap); } throw new InvalidOperationException($"No reader found for xsi:type - {xsiType}"); diff --git a/SysML2.NET.Serializer.Xmi/Readers/IXmiDataReaderFacade.cs b/SysML2.NET.Serializer.Xmi/Readers/IXmiDataReaderFacade.cs index 9ea0b5cfa..1e1c8e6f6 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/IXmiDataReaderFacade.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/IXmiDataReaderFacade.cs @@ -44,9 +44,10 @@ public interface IXmiDataReaderFacade /// The used to register and process external references /// The used to set up logging /// The explicit type name to resolve, in case of un-specified xsi:type + /// The optional used to track element-to-file associations /// An instance of the read /// If the xsi:type is not supported - IData QueryXmiData(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = ""); + IData QueryXmiData(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = "", IXmiElementOriginMap elementOriginMap = null); /// /// Queries asynchronously an instance of an based on the position of the . @@ -59,8 +60,9 @@ public interface IXmiDataReaderFacade /// The used to register and process external references /// The used to set up logging /// The explicit type name to resolve, in case of un-specified xsi:type + /// The optional used to track element-to-file associations /// An awaitable with the instance of the read /// If the xsi:type is not supported - Task QueryXmiDataAsync(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = ""); + Task QueryXmiDataAsync(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = "", IXmiElementOriginMap elementOriginMap = null); } } diff --git a/SysML2.NET.Serializer.Xmi/Readers/XmiDataReader.cs b/SysML2.NET.Serializer.Xmi/Readers/XmiDataReader.cs index cb1554f4e..02ed4305c 100644 --- a/SysML2.NET.Serializer.Xmi/Readers/XmiDataReader.cs +++ b/SysML2.NET.Serializer.Xmi/Readers/XmiDataReader.cs @@ -54,6 +54,11 @@ public abstract class XmiDataReader where TData : IData /// protected readonly IExternalReferenceService ExternalReferenceService; + /// + /// The optional used to track element-to-file associations + /// + protected readonly IXmiElementOriginMap ElementOriginMap; + /// /// the character used to split the values (of xml attributes) using a white space as separator /// @@ -69,12 +74,14 @@ public abstract class XmiDataReader where TData : IData /// /// The injected used to register and process external references /// The injected used to set up logging - protected XmiDataReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory) + /// The optional used to track element-to-file associations + protected XmiDataReader(IXmiDataCache cache, IXmiDataReaderFacade xmiDataReaderFacade, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, IXmiElementOriginMap elementOriginMap = null) { this.LoggerFactory = loggerFactory; this.XmiDataReaderFacade = xmiDataReaderFacade; this.Cache = cache; this.ExternalReferenceService = externalReferenceService; + this.ElementOriginMap = elementOriginMap; } /// diff --git a/SysML2.NET.Serializer.Xmi/Serializer.cs b/SysML2.NET.Serializer.Xmi/Serializer.cs new file mode 100644 index 000000000..3cf653cc2 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Serializer.cs @@ -0,0 +1,569 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi +{ + using System; + using System.Diagnostics; + using System.IO; + using System.Linq; + using System.Threading; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Serializer.Xmi.Writers; + + /// + /// The purpose of the is to write an + /// as XMI to a + /// + public class Serializer : ISerializer + { + /// + /// Gets the URI of the XMI namespace location + /// + private const string XmiNamespace = "http://www.omg.org/spec/XMI/20131001"; + + /// + /// Gets the URI of the XSI namespace location + /// + private const string XsiNamespace = "http://www.w3.org/2001/XMLSchema-instance"; + + /// + /// Gets the URI of the SysML namespace location + /// + private const string SysmlNamespace = "https://www.omg.org/spec/SysML/20250201"; + + /// + /// Gets the instance to perform logging statement + /// + private readonly ILogger logger; + + /// + /// Gets the to dispatch writing + /// + private readonly XmiDataWriterFacade xmiWriterFacade; + + /// Initializes a new instance of the class. + /// The injected used to set up logging + public Serializer(ILoggerFactory loggerFactory) + { + this.logger = loggerFactory.CreateLogger(); + + this.xmiWriterFacade = new XmiDataWriterFacade(loggerFactory); + } + + /// + /// Serialize an as XMI to a target + /// + /// + /// The that shall be serialized + /// + /// The instance that provides writer output configuration + /// + /// The target + /// + public void Serialize(INamespace @namespace, XmiWriterOptions writerOptions, Stream stream) + { + this.Serialize(@namespace, writerOptions, stream, null, null); + } + + /// + /// Serialize an as XMI to a target , + /// using an origin map for href reconstruction + /// + /// + /// The that shall be serialized + /// + /// The instance that provides writer output configuration + /// + /// The target + /// + /// + /// The optional for href reconstruction + /// + /// + /// The optional of the current output file for relative href computation + /// + public void Serialize(INamespace @namespace, XmiWriterOptions writerOptions, Stream stream, IXmiElementOriginMap elementOriginMap, Uri currentFileUri) + { + if (@namespace == null) + { + throw new ArgumentNullException(nameof(@namespace)); + } + + if (stream == null) + { + throw new ArgumentNullException(nameof(stream)); + } + + var sw = Stopwatch.StartNew(); + + this.logger.LogInformation("Setting up XMI serialization"); + + writerOptions ??= new XmiWriterOptions(); + + var settings = new XmlWriterSettings + { + Indent = true, + IndentChars = " ", + NewLineChars = "\n", + NewLineHandling = NewLineHandling.Replace, + OmitXmlDeclaration = false, + Encoding = new System.Text.UTF8Encoding(false) + }; + + using var xmlWriter = XmlWriter.Create(stream, settings); + + this.logger.LogInformation("Starting XMI serialization"); + + xmlWriter.WriteStartDocument(); + + this.WriteNamespaceElement(xmlWriter, @namespace, elementOriginMap, currentFileUri, writerOptions); + + xmlWriter.WriteEndDocument(); + xmlWriter.Flush(); + + this.logger.LogInformation("XMI serialization completed in {ElapsedMilliseconds} [ms]", sw.ElapsedMilliseconds); + } + + /// + /// Serialize an to multiple XMI files based on the element origin map + /// + /// The root containing all elements + /// The tracking element-to-file associations + /// The target directory for output files + /// The instance that provides writer output configuration + public void Serialize(INamespace rootNamespace, IXmiElementOriginMap elementOriginMap, DirectoryInfo outputDirectory, XmiWriterOptions writerOptions) + { + if (rootNamespace == null) + { + throw new ArgumentNullException(nameof(rootNamespace)); + } + + if (elementOriginMap == null) + { + throw new ArgumentNullException(nameof(elementOriginMap)); + } + + if (outputDirectory == null) + { + throw new ArgumentNullException(nameof(outputDirectory)); + } + + var sw = Stopwatch.StartNew(); + + this.logger.LogInformation("Setting up multi-file XMI serialization"); + + writerOptions ??= new XmiWriterOptions(); + + if (!outputDirectory.Exists) + { + outputDirectory.Create(); + } + + var sourceFiles = elementOriginMap.GetAllSourceFiles().ToList(); + + this.logger.LogInformation("Starting multi-file XMI serialization for {FileCount} files", sourceFiles.Count); + + // Build a flat index of all namespaces for O(1) lookup + var namespaceIndex = new System.Collections.Generic.Dictionary(); + BuildNamespaceIndex(rootNamespace, namespaceIndex); + + foreach (var sourceFile in sourceFiles) + { + var rootNamespaceId = elementOriginMap.GetRootNamespaceId(sourceFile); + + if (rootNamespaceId == Guid.Empty) + { + this.logger.LogWarning("No root namespace found for source file {SourceFile}", sourceFile); + continue; + } + + // Compute relative path from original source structure + var fileName = Path.GetFileName(sourceFile.LocalPath); + var outputPath = Path.Combine(outputDirectory.FullName, fileName); + var outputUri = new Uri(outputPath); + + this.logger.LogInformation("Writing XMI at: {FileName}", fileName); + + // Find the namespace POCO for this file's root namespace + if (!namespaceIndex.TryGetValue(rootNamespaceId, out var fileRootNamespace)) + { + this.logger.LogWarning("Could not find namespace with id {NamespaceId} for file {SourceFile}", rootNamespaceId, sourceFile); + continue; + } + + using var fileStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write, FileShare.None, 4096); + this.Serialize(fileRootNamespace, writerOptions, fileStream, elementOriginMap, outputUri); + } + + this.logger.LogInformation("Multi-file XMI serialization completed in {ElapsedMilliseconds} [ms]", sw.ElapsedMilliseconds); + } + + /// + /// Asynchronously serialize an as XMI to a target + /// + /// + /// The that shall be serialized + /// + /// + /// The target + /// + /// The instance that provides writer output configuration + /// + /// The used to cancel the operation + /// + public async Task SerializeAsync(INamespace @namespace, XmiWriterOptions writerOptions, Stream stream, CancellationToken cancellationToken) + { + await this.SerializeAsync(@namespace, writerOptions, stream, null, null, cancellationToken); + } + + /// + /// Asynchronously serialize an as XMI to a target , + /// using an origin map for href reconstruction + /// + /// + /// The that shall be serialized + /// + /// The instance that provides writer output configuration + /// + /// The target + /// + /// + /// The optional for href reconstruction + /// + /// + /// The optional of the current output file for relative href computation + /// + /// + /// The used to cancel the operation + /// + public async Task SerializeAsync(INamespace @namespace, XmiWriterOptions writerOptions, Stream stream, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, CancellationToken cancellationToken) + { + if (@namespace == null) + { + throw new ArgumentNullException(nameof(@namespace)); + } + + if (stream == null) + { + throw new ArgumentNullException(nameof(stream)); + } + + var sw = Stopwatch.StartNew(); + + this.logger.LogInformation("Setting up asynchronous XMI serialization"); + + writerOptions ??= new XmiWriterOptions(); + + var settings = new XmlWriterSettings + { + Async = true, + Indent = true, + IndentChars = " ", + NewLineChars = "\n", + NewLineHandling = NewLineHandling.Replace, + OmitXmlDeclaration = false, + Encoding = new System.Text.UTF8Encoding(false) + }; + + using var xmlWriter = XmlWriter.Create(stream, settings); + + this.logger.LogInformation("Starting asynchronous XMI serialization"); + + await xmlWriter.WriteStartDocumentAsync(); + + await this.WriteNamespaceElementAsync(xmlWriter, @namespace, elementOriginMap, currentFileUri, writerOptions); + + await xmlWriter.WriteEndDocumentAsync(); + await xmlWriter.FlushAsync(); + + this.logger.LogInformation("Asynchronous XMI serialization completed in {ElapsedMilliseconds} [ms]", sw.ElapsedMilliseconds); + } + + /// + /// Asynchronously serialize an to multiple XMI files based on the element origin map + /// + /// The root containing all elements + /// The tracking element-to-file associations + /// The target directory for output files + /// The instance that provides writer output configuration + /// + /// The used to cancel the operation + /// + public async Task SerializeAsync(INamespace rootNamespace, IXmiElementOriginMap elementOriginMap, DirectoryInfo outputDirectory, XmiWriterOptions writerOptions, CancellationToken cancellationToken) + { + if (rootNamespace == null) + { + throw new ArgumentNullException(nameof(rootNamespace)); + } + + if (elementOriginMap == null) + { + throw new ArgumentNullException(nameof(elementOriginMap)); + } + + if (outputDirectory == null) + { + throw new ArgumentNullException(nameof(outputDirectory)); + } + + var sw = Stopwatch.StartNew(); + + this.logger.LogInformation("Setting up asynchronous multi-file XMI serialization"); + + writerOptions ??= new XmiWriterOptions(); + + if (!outputDirectory.Exists) + { + outputDirectory.Create(); + } + + var sourceFiles = elementOriginMap.GetAllSourceFiles().ToList(); + + this.logger.LogInformation("Starting asynchronous multi-file XMI serialization for {FileCount} files", sourceFiles.Count); + + // Build a flat index of all namespaces for O(1) lookup + var namespaceIndex = new System.Collections.Generic.Dictionary(); + BuildNamespaceIndex(rootNamespace, namespaceIndex); + + foreach (var sourceFile in sourceFiles) + { + cancellationToken.ThrowIfCancellationRequested(); + + var rootNamespaceId = elementOriginMap.GetRootNamespaceId(sourceFile); + + if (rootNamespaceId == Guid.Empty) + { + this.logger.LogWarning("No root namespace found for source file {SourceFile}", sourceFile); + continue; + } + + // Compute relative path from original source structure + var fileName = Path.GetFileName(sourceFile.LocalPath); + var outputPath = Path.Combine(outputDirectory.FullName, fileName); + var outputUri = new Uri(outputPath); + + this.logger.LogInformation("Writing XMI at: {FileName}", fileName); + + // Find the namespace POCO for this file's root namespace + if (!namespaceIndex.TryGetValue(rootNamespaceId, out var fileRootNamespace)) + { + this.logger.LogWarning("Could not find namespace with id {NamespaceId} for file {SourceFile}", rootNamespaceId, sourceFile); + continue; + } + + await using var fileStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write, FileShare.None, 4096, useAsync: true); + await this.SerializeAsync(fileRootNamespace, writerOptions, fileStream, elementOriginMap, outputUri, cancellationToken); + } + + this.logger.LogInformation("Asynchronous multi-file XMI serialization completed in {ElapsedMilliseconds} [ms]", sw.ElapsedMilliseconds); + } + + /// + /// Writes the XML content for the root + /// + /// The instance that provides XMI write features + /// The root to write + /// The tracking element-to-file associations + /// The that locates the output file + /// The instance that provides writer output configuration + private void WriteNamespaceElement(XmlWriter xmlWriter, INamespace @namespace, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, XmiWriterOptions writerOptions) + { + xmlWriter.WriteStartElement("sysml", "Namespace", SysmlNamespace); + xmlWriter.WriteAttributeString("xmlns", "xmi", null, XmiNamespace); + xmlWriter.WriteAttributeString("xmlns", "xsi", null, XsiNamespace); + xmlWriter.WriteAttributeString("xmi", "id", XmiNamespace, @namespace.Id.ToString()); + + // Write scalar properties + if (@namespace.AliasIds != null && @namespace.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", @namespace.AliasIds)); + } + + if (!string.IsNullOrEmpty(@namespace.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", @namespace.DeclaredName); + } + + if (!string.IsNullOrEmpty(@namespace.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", @namespace.DeclaredShortName); + } + + if (!string.IsNullOrEmpty(@namespace.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", @namespace.ElementId); + } + + if (writerOptions.IncludeImplied || @namespace.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + // Write owned relationships as child elements + if (@namespace.OwnedRelationship != null) + { + foreach (var relationship in @namespace.OwnedRelationship) + { + if (!writerOptions.IncludeImplied && relationship is { IsImplied: true }) + { + continue; + } + + if (relationship is IData relationshipData) + { + if (elementOriginMap != null && currentFileUri != null) + { + var childSourceFile = elementOriginMap.GetSourceFile(relationshipData.Id); + + if (childSourceFile != null && childSourceFile != currentFileUri) + { + var relativePath = currentFileUri.MakeRelativeUri(childSourceFile); + var href = $"{Uri.UnescapeDataString(relativePath.ToString())}#{relationshipData.Id}"; + + xmlWriter.WriteStartElement("ownedRelationship"); + xmlWriter.WriteAttributeString("href", href); + xmlWriter.WriteEndElement(); + continue; + } + } + + this.xmiWriterFacade.Write(xmlWriter, relationshipData, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the XML content for the root + /// + /// The instance that provides XMI write features + /// The root to write + /// The tracking element-to-file associations + /// The that locates the output file + /// The instance that provides writer output configuration + private async Task WriteNamespaceElementAsync(XmlWriter xmlWriter, INamespace @namespace, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, XmiWriterOptions writerOptions) + { + await xmlWriter.WriteStartElementAsync("sysml", "Namespace", SysmlNamespace); + await xmlWriter.WriteAttributeStringAsync("xmlns", "xmi", null, XmiNamespace); + await xmlWriter.WriteAttributeStringAsync("xmlns", "xsi", null, XsiNamespace); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", XmiNamespace, @namespace.Id.ToString()); + + // Write scalar properties + if (@namespace.AliasIds != null && @namespace.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", @namespace.AliasIds)); + } + + if (!string.IsNullOrEmpty(@namespace.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, @namespace.DeclaredName); + } + + if (!string.IsNullOrEmpty(@namespace.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, @namespace.DeclaredShortName); + } + + if (!string.IsNullOrEmpty(@namespace.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, @namespace.ElementId); + } + + if (writerOptions.IncludeImplied || @namespace.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + // Write owned relationships as child elements + if (@namespace.OwnedRelationship != null) + { + foreach (var relationship in @namespace.OwnedRelationship) + { + if (!writerOptions.IncludeImplied && relationship is { IsImplied: true }) + { + continue; + } + + if (relationship is IData relationshipData) + { + if (elementOriginMap != null && currentFileUri != null) + { + var childSourceFile = elementOriginMap.GetSourceFile(relationshipData.Id); + + if (childSourceFile != null && childSourceFile != currentFileUri) + { + var relativePath = currentFileUri.MakeRelativeUri(childSourceFile); + var href = $"{Uri.UnescapeDataString(relativePath.ToString())}#{relationshipData.Id}"; + + await xmlWriter.WriteStartElementAsync(null, "ownedRelationship", null); + await xmlWriter.WriteAttributeStringAsync(null, "href", null, href); + await xmlWriter.WriteEndElementAsync(); + continue; + } + } + + await this.xmiWriterFacade.WriteAsync(xmlWriter, relationshipData, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + await xmlWriter.WriteEndElementAsync(); + } + + /// + /// Builds a flat index of all instances reachable from the root + /// + /// The root used as starting point + /// The dictionary to populate with namespace id to instance mappings + private static void BuildNamespaceIndex(INamespace root, System.Collections.Generic.Dictionary index) + { + index[root.Id] = root; + + if (root.OwnedRelationship == null) + { + return; + } + + foreach (var relationship in root.OwnedRelationship) + { + if (relationship is IElement element && element.OwnedRelationship != null) + { + foreach (var child in element.OwnedRelationship) + { + if (child is INamespace childNamespace) + { + BuildNamespaceIndex(childNamespace, index); + } + } + } + } + } + } +} diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AcceptActionUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AcceptActionUsageWriter.cs new file mode 100644 index 000000000..a8b9fb1b3 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AcceptActionUsageWriter.cs @@ -0,0 +1,2583 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class AcceptActionUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public AcceptActionUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IAcceptActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:AcceptActionUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.payloadArgument != null && poco.payloadArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("payloadArgument", poco.payloadArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.payloadParameter != null && poco.payloadParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("payloadParameter", poco.payloadParameter.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.receiverArgument != null && poco.receiverArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("receiverArgument", poco.receiverArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.payloadArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.payloadArgument, "payloadArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.payloadParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.payloadParameter, "payloadParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.receiverArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.receiverArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.receiverArgument, "receiverArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IAcceptActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:AcceptActionUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.payloadArgument != null && poco.payloadArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "payloadArgument", null, poco.payloadArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.payloadParameter != null && poco.payloadParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "payloadParameter", null, poco.payloadParameter.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.receiverArgument != null && poco.receiverArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "receiverArgument", null, poco.receiverArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.payloadArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.payloadArgument, "payloadArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.payloadParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.payloadParameter, "payloadParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.receiverArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.receiverArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.receiverArgument, "receiverArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ActionDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ActionDefinitionWriter.cs new file mode 100644 index 000000000..dc3a2de1c --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ActionDefinitionWriter.cs @@ -0,0 +1,1859 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ActionDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ActionDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IActionDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ActionDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IActionDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ActionDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ActionUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ActionUsageWriter.cs new file mode 100644 index 000000000..bf7cf9a75 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ActionUsageWriter.cs @@ -0,0 +1,2468 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ActionUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ActionUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ActionUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ActionUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ActorMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ActorMembershipWriter.cs new file mode 100644 index 000000000..5c84d00f8 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ActorMembershipWriter.cs @@ -0,0 +1,553 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ActorMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ActorMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IActorMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ActorMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedActorParameter != null && poco.ownedActorParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedActorParameter", poco.ownedActorParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedActorParameter != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedActorParameter, "ownedActorParameter", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IActorMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ActorMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedActorParameter != null && poco.ownedActorParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedActorParameter", null, poco.ownedActorParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedActorParameter != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedActorParameter, "ownedActorParameter", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AllocationDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AllocationDefinitionWriter.cs new file mode 100644 index 000000000..a1676935c --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AllocationDefinitionWriter.cs @@ -0,0 +1,1945 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class AllocationDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public AllocationDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IAllocationDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:AllocationDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (!poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceType != null && poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceType", poco.sourceType.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.allocation != null) + { + foreach (var item in poco.allocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "allocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectionEnd != null) + { + foreach (var item in poco.connectionEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "connectionEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedType != null) + { + foreach (var item in poco.relatedType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceType, "sourceType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetType != null) + { + foreach (var item in poco.targetType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IAllocationDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:AllocationDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (!poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceType != null && poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceType", null, poco.sourceType.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.allocation != null) + { + foreach (var item in poco.allocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "allocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectionEnd != null) + { + foreach (var item in poco.connectionEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "connectionEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedType != null) + { + foreach (var item in poco.relatedType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceType, "sourceType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetType != null) + { + foreach (var item in poco.targetType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AllocationUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AllocationUsageWriter.cs new file mode 100644 index 000000000..69fdbff4e --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AllocationUsageWriter.cs @@ -0,0 +1,2660 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Kernel.Structures; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class AllocationUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public AllocationUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IAllocationUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:AllocationUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("defaultFeaturingType", poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceFeature", poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.allocationDefinition != null) + { + foreach (var item in poco.allocationDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "allocationDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.partDefinition != null) + { + foreach (var item in poco.partDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "partDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IAllocationUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:AllocationUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "defaultFeaturingType", null, poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceFeature", null, poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.allocationDefinition != null) + { + foreach (var item in poco.allocationDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "allocationDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.partDefinition != null) + { + foreach (var item in poco.partDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "partDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AnalysisCaseDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AnalysisCaseDefinitionWriter.cs new file mode 100644 index 000000000..c59e1e523 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AnalysisCaseDefinitionWriter.cs @@ -0,0 +1,2094 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class AnalysisCaseDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public AnalysisCaseDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IAnalysisCaseDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:AnalysisCaseDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("objectiveRequirement", poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.resultExpression != null && poco.resultExpression.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("resultExpression", poco.resultExpression.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.calculation != null) + { + foreach (var item in poco.calculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "calculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.resultExpression != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.resultExpression.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.resultExpression, "resultExpression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IAnalysisCaseDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:AnalysisCaseDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "objectiveRequirement", null, poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.resultExpression != null && poco.resultExpression.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "resultExpression", null, poco.resultExpression.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.calculation != null) + { + foreach (var item in poco.calculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "calculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.resultExpression != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.resultExpression.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.resultExpression, "resultExpression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AnalysisCaseUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AnalysisCaseUsageWriter.cs new file mode 100644 index 000000000..bdd2a4fca --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AnalysisCaseUsageWriter.cs @@ -0,0 +1,2697 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class AnalysisCaseUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public AnalysisCaseUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IAnalysisCaseUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:AnalysisCaseUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.analysisCaseDefinition != null && poco.analysisCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("analysisCaseDefinition", poco.analysisCaseDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("objectiveRequirement", poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.resultExpression != null && poco.resultExpression.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("resultExpression", poco.resultExpression.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.analysisCaseDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.analysisCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.analysisCaseDefinition, "analysisCaseDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.resultExpression != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.resultExpression.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.resultExpression, "resultExpression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IAnalysisCaseUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:AnalysisCaseUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.analysisCaseDefinition != null && poco.analysisCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "analysisCaseDefinition", null, poco.analysisCaseDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "objectiveRequirement", null, poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.resultExpression != null && poco.resultExpression.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "resultExpression", null, poco.resultExpression.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.analysisCaseDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.analysisCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.analysisCaseDefinition, "analysisCaseDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.resultExpression != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.resultExpression.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.resultExpression, "resultExpression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AnnotatingElementWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AnnotatingElementWriter.cs new file mode 100644 index 000000000..19db5c1b7 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AnnotatingElementWriter.cs @@ -0,0 +1,475 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class AnnotatingElementWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public AnnotatingElementWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IAnnotatingElement poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:AnnotatingElement"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotatedElement != null) + { + foreach (var item in poco.annotatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "annotatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotation != null) + { + foreach (var item in poco.annotation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "annotation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotatingRelationship != null) + { + foreach (var item in poco.ownedAnnotatingRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotatingRelationship", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IAnnotatingElement poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:AnnotatingElement"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotatedElement != null) + { + foreach (var item in poco.annotatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "annotatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotation != null) + { + foreach (var item in poco.annotation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "annotation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotatingRelationship != null) + { + foreach (var item in poco.ownedAnnotatingRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotatingRelationship", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AnnotationWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AnnotationWriter.cs new file mode 100644 index 000000000..c42a6d450 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AnnotationWriter.cs @@ -0,0 +1,553 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class AnnotationWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public AnnotationWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IAnnotation poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Annotation"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.AnnotatedElement != null && poco.AnnotatedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("annotatedElement", poco.AnnotatedElement.Id.ToString()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.annotatingElement != null && poco.annotatingElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("annotatingElement", poco.annotatingElement.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedAnnotatingElement != null && poco.ownedAnnotatingElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedAnnotatingElement", poco.ownedAnnotatingElement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.AnnotatedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.AnnotatedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.AnnotatedElement, "annotatedElement", elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotatingElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.annotatingElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.annotatingElement, "annotatingElement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotatingElement != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedAnnotatingElement, "ownedAnnotatingElement", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IAnnotation poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Annotation"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.AnnotatedElement != null && poco.AnnotatedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "annotatedElement", null, poco.AnnotatedElement.Id.ToString()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.annotatingElement != null && poco.annotatingElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "annotatingElement", null, poco.annotatingElement.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedAnnotatingElement != null && poco.ownedAnnotatingElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedAnnotatingElement", null, poco.ownedAnnotatingElement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.AnnotatedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.AnnotatedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.AnnotatedElement, "annotatedElement", elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotatingElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.annotatingElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.annotatingElement, "annotatingElement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotatingElement != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedAnnotatingElement, "ownedAnnotatingElement", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AssertConstraintUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AssertConstraintUsageWriter.cs new file mode 100644 index 000000000..4fa5747bc --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AssertConstraintUsageWriter.cs @@ -0,0 +1,2587 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class AssertConstraintUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public AssertConstraintUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IAssertConstraintUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:AssertConstraintUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.assertedConstraint != null && poco.assertedConstraint.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("assertedConstraint", poco.assertedConstraint.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.constraintDefinition != null && poco.constraintDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("constraintDefinition", poco.constraintDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsNegated) + { + xmlWriter.WriteAttributeString("isNegated", "true"); + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assertedConstraint != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.assertedConstraint.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.assertedConstraint, "assertedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.constraintDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.constraintDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.constraintDefinition, "constraintDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IAssertConstraintUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:AssertConstraintUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.assertedConstraint != null && poco.assertedConstraint.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "assertedConstraint", null, poco.assertedConstraint.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.constraintDefinition != null && poco.constraintDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "constraintDefinition", null, poco.constraintDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsNegated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isNegated", null, "true"); + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assertedConstraint != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.assertedConstraint.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.assertedConstraint, "assertedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.constraintDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.constraintDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.constraintDefinition, "constraintDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AssignmentActionUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AssignmentActionUsageWriter.cs new file mode 100644 index 000000000..0ea59a98e --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AssignmentActionUsageWriter.cs @@ -0,0 +1,2583 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class AssignmentActionUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public AssignmentActionUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IAssignmentActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:AssignmentActionUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.referent != null && poco.referent.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("referent", poco.referent.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.targetArgument != null && poco.targetArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("targetArgument", poco.targetArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.valueExpression != null && poco.valueExpression.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("valueExpression", poco.valueExpression.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.referent != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.referent.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.referent, "referent", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.targetArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.targetArgument, "targetArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.valueExpression != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.valueExpression.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.valueExpression, "valueExpression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IAssignmentActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:AssignmentActionUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.referent != null && poco.referent.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "referent", null, poco.referent.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.targetArgument != null && poco.targetArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "targetArgument", null, poco.targetArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.valueExpression != null && poco.valueExpression.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "valueExpression", null, poco.valueExpression.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.referent != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.referent.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.referent, "referent", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.targetArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.targetArgument, "targetArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.valueExpression != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.valueExpression.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.valueExpression, "valueExpression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AssociationStructureWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AssociationStructureWriter.cs new file mode 100644 index 000000000..d444056fa --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AssociationStructureWriter.cs @@ -0,0 +1,1200 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Structures; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class AssociationStructureWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public AssociationStructureWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IAssociationStructure poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:AssociationStructure"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceType != null && poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceType", poco.sourceType.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.associationEnd != null) + { + foreach (var item in poco.associationEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "associationEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedType != null) + { + foreach (var item in poco.relatedType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceType, "sourceType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetType != null) + { + foreach (var item in poco.targetType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IAssociationStructure poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:AssociationStructure"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceType != null && poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceType", null, poco.sourceType.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.associationEnd != null) + { + foreach (var item in poco.associationEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "associationEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedType != null) + { + foreach (var item in poco.relatedType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceType, "sourceType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetType != null) + { + foreach (var item in poco.targetType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AssociationWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AssociationWriter.cs new file mode 100644 index 000000000..199c92563 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AssociationWriter.cs @@ -0,0 +1,1199 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class AssociationWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public AssociationWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IAssociation poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Association"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceType != null && poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceType", poco.sourceType.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.associationEnd != null) + { + foreach (var item in poco.associationEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "associationEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedType != null) + { + foreach (var item in poco.relatedType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceType, "sourceType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetType != null) + { + foreach (var item in poco.targetType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IAssociation poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Association"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceType != null && poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceType", null, poco.sourceType.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.associationEnd != null) + { + foreach (var item in poco.associationEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "associationEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedType != null) + { + foreach (var item in poco.relatedType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceType, "sourceType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetType != null) + { + foreach (var item in poco.targetType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AttributeDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AttributeDefinitionWriter.cs new file mode 100644 index 000000000..6912cb629 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AttributeDefinitionWriter.cs @@ -0,0 +1,1805 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.DataTypes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class AttributeDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public AttributeDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IAttributeDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:AttributeDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IAttributeDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:AttributeDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AttributeUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AttributeUsageWriter.cs new file mode 100644 index 000000000..8984c57da --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/AttributeUsageWriter.cs @@ -0,0 +1,2386 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.DataTypes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class AttributeUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public AttributeUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IAttributeUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:AttributeUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "false"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.attributeDefinition != null) + { + foreach (var item in poco.attributeDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "attributeDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IAttributeUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:AttributeUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "false"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.attributeDefinition != null) + { + foreach (var item in poco.attributeDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "attributeDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/BehaviorWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/BehaviorWriter.cs new file mode 100644 index 000000000..85b7b4791 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/BehaviorWriter.cs @@ -0,0 +1,1114 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class BehaviorWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public BehaviorWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IBehavior poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Behavior"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IBehavior poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Behavior"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/BindingConnectorAsUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/BindingConnectorAsUsageWriter.cs new file mode 100644 index 000000000..5d8c80995 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/BindingConnectorAsUsageWriter.cs @@ -0,0 +1,2555 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class BindingConnectorAsUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public BindingConnectorAsUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IBindingConnectorAsUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:BindingConnectorAsUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("defaultFeaturingType", poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceFeature", poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.association != null) + { + foreach (var item in poco.association) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "association", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.definition != null) + { + foreach (var item in poco.definition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "definition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IBindingConnectorAsUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:BindingConnectorAsUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "defaultFeaturingType", null, poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceFeature", null, poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.association != null) + { + foreach (var item in poco.association) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "association", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.definition != null) + { + foreach (var item in poco.definition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "definition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/BindingConnectorWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/BindingConnectorWriter.cs new file mode 100644 index 000000000..acf605745 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/BindingConnectorWriter.cs @@ -0,0 +1,1720 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class BindingConnectorWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public BindingConnectorWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IBindingConnector poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:BindingConnector"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("defaultFeaturingType", poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceFeature", poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.association != null) + { + foreach (var item in poco.association) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "association", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IBindingConnector poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:BindingConnector"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "defaultFeaturingType", null, poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceFeature", null, poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.association != null) + { + foreach (var item in poco.association) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "association", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/BooleanExpressionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/BooleanExpressionWriter.cs new file mode 100644 index 000000000..f17cf69cf --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/BooleanExpressionWriter.cs @@ -0,0 +1,1666 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class BooleanExpressionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public BooleanExpressionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IBooleanExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:BooleanExpression"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.predicate != null && poco.predicate.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("predicate", poco.predicate.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.predicate != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.predicate.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.predicate, "predicate", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IBooleanExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:BooleanExpression"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.predicate != null && poco.predicate.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "predicate", null, poco.predicate.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.predicate != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.predicate.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.predicate, "predicate", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CalculationDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CalculationDefinitionWriter.cs new file mode 100644 index 000000000..0b739c5d7 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CalculationDefinitionWriter.cs @@ -0,0 +1,1958 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class CalculationDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public CalculationDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ICalculationDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:CalculationDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.calculation != null) + { + foreach (var item in poco.calculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "calculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ICalculationDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:CalculationDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.calculation != null) + { + foreach (var item in poco.calculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "calculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CalculationUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CalculationUsageWriter.cs new file mode 100644 index 000000000..39111e63c --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CalculationUsageWriter.cs @@ -0,0 +1,2561 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class CalculationUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public CalculationUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ICalculationUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:CalculationUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.calculationDefinition != null && poco.calculationDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("calculationDefinition", poco.calculationDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.calculationDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.calculationDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.calculationDefinition, "calculationDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ICalculationUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:CalculationUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.calculationDefinition != null && poco.calculationDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "calculationDefinition", null, poco.calculationDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.calculationDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.calculationDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.calculationDefinition, "calculationDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CaseDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CaseDefinitionWriter.cs new file mode 100644 index 000000000..47678d638 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CaseDefinitionWriter.cs @@ -0,0 +1,2056 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class CaseDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public CaseDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ICaseDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:CaseDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("objectiveRequirement", poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.calculation != null) + { + foreach (var item in poco.calculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "calculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ICaseDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:CaseDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "objectiveRequirement", null, poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.calculation != null) + { + foreach (var item in poco.calculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "calculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CaseUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CaseUsageWriter.cs new file mode 100644 index 000000000..e0f529925 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CaseUsageWriter.cs @@ -0,0 +1,2659 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class CaseUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public CaseUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ICaseUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:CaseUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.caseDefinition != null && poco.caseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("caseDefinition", poco.caseDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("objectiveRequirement", poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.caseDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.caseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.caseDefinition, "caseDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ICaseUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:CaseUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.caseDefinition != null && poco.caseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "caseDefinition", null, poco.caseDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "objectiveRequirement", null, poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.caseDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.caseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.caseDefinition, "caseDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ClassWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ClassWriter.cs new file mode 100644 index 000000000..a30436fb1 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ClassWriter.cs @@ -0,0 +1,1091 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ClassWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ClassWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IClass poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Class"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IClass poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Class"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ClassifierWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ClassifierWriter.cs new file mode 100644 index 000000000..4c7f739f1 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ClassifierWriter.cs @@ -0,0 +1,1090 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ClassifierWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ClassifierWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IClassifier poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Classifier"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IClassifier poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Classifier"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CollectExpressionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CollectExpressionWriter.cs new file mode 100644 index 000000000..fa51abcee --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CollectExpressionWriter.cs @@ -0,0 +1,1743 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class CollectExpressionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public CollectExpressionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ICollectExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:CollectExpression"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("instantiatedType", poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (poco.Operator != "collect") + { + if (!string.IsNullOrWhiteSpace(poco.Operator)) + { + xmlWriter.WriteAttributeString("operator", poco.Operator); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ICollectExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:CollectExpression"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "instantiatedType", null, poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (poco.Operator != "collect") + { + if (!string.IsNullOrWhiteSpace(poco.Operator)) + { + await xmlWriter.WriteAttributeStringAsync(null, "operator", null, poco.Operator); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CommentWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CommentWriter.cs new file mode 100644 index 000000000..0dd0c7f9b --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CommentWriter.cs @@ -0,0 +1,495 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class CommentWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public CommentWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IComment poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Comment"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.Body)) + { + xmlWriter.WriteAttributeString("body", poco.Body); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (!string.IsNullOrWhiteSpace(poco.Locale)) + { + xmlWriter.WriteAttributeString("locale", poco.Locale); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotatedElement != null) + { + foreach (var item in poco.annotatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "annotatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotation != null) + { + foreach (var item in poco.annotation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "annotation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotatingRelationship != null) + { + foreach (var item in poco.ownedAnnotatingRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotatingRelationship", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IComment poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Comment"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.Body)) + { + await xmlWriter.WriteAttributeStringAsync(null, "body", null, poco.Body); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (!string.IsNullOrWhiteSpace(poco.Locale)) + { + await xmlWriter.WriteAttributeStringAsync(null, "locale", null, poco.Locale); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotatedElement != null) + { + foreach (var item in poco.annotatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "annotatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotation != null) + { + foreach (var item in poco.annotation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "annotation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotatingRelationship != null) + { + foreach (var item in poco.ownedAnnotatingRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotatingRelationship", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConcernDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConcernDefinitionWriter.cs new file mode 100644 index 000000000..6d2f0371e --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConcernDefinitionWriter.cs @@ -0,0 +1,2078 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ConcernDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ConcernDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IConcernDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ConcernDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ReqId)) + { + xmlWriter.WriteAttributeString("reqId", poco.ReqId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.text != null && poco.text.Count > 0) + { + xmlWriter.WriteAttributeString("text", string.Join(" ", poco.text)); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assumedConstraint != null) + { + foreach (var item in poco.assumedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "assumedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.framedConcern != null) + { + foreach (var item in poco.framedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "framedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requiredConstraint != null) + { + foreach (var item in poco.requiredConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "requiredConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stakeholderParameter != null) + { + foreach (var item in poco.stakeholderParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "stakeholderParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IConcernDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ConcernDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ReqId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "reqId", null, poco.ReqId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.text != null && poco.text.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "text", null, string.Join(" ", poco.text)); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assumedConstraint != null) + { + foreach (var item in poco.assumedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "assumedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.framedConcern != null) + { + foreach (var item in poco.framedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "framedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requiredConstraint != null) + { + foreach (var item in poco.requiredConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "requiredConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stakeholderParameter != null) + { + foreach (var item in poco.stakeholderParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "stakeholderParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConcernUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConcernUsageWriter.cs new file mode 100644 index 000000000..5e6c2bf72 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConcernUsageWriter.cs @@ -0,0 +1,2703 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ConcernUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ConcernUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IConcernUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ConcernUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.concernDefinition != null && poco.concernDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("concernDefinition", poco.concernDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ReqId)) + { + xmlWriter.WriteAttributeString("reqId", poco.ReqId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.text != null && poco.text.Count > 0) + { + xmlWriter.WriteAttributeString("text", string.Join(" ", poco.text)); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assumedConstraint != null) + { + foreach (var item in poco.assumedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "assumedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.concernDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.concernDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.concernDefinition, "concernDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.framedConcern != null) + { + foreach (var item in poco.framedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "framedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requiredConstraint != null) + { + foreach (var item in poco.requiredConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "requiredConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stakeholderParameter != null) + { + foreach (var item in poco.stakeholderParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "stakeholderParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IConcernUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ConcernUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.concernDefinition != null && poco.concernDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "concernDefinition", null, poco.concernDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ReqId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "reqId", null, poco.ReqId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.text != null && poco.text.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "text", null, string.Join(" ", poco.text)); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assumedConstraint != null) + { + foreach (var item in poco.assumedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "assumedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.concernDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.concernDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.concernDefinition, "concernDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.framedConcern != null) + { + foreach (var item in poco.framedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "framedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requiredConstraint != null) + { + foreach (var item in poco.requiredConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "requiredConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stakeholderParameter != null) + { + foreach (var item in poco.stakeholderParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "stakeholderParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConjugatedPortDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConjugatedPortDefinitionWriter.cs new file mode 100644 index 000000000..418f9580a --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConjugatedPortDefinitionWriter.cs @@ -0,0 +1,1858 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ConjugatedPortDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ConjugatedPortDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IConjugatedPortDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ConjugatedPortDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.conjugatedPortDefinition != null && poco.conjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("conjugatedPortDefinition", poco.conjugatedPortDefinition.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.originalPortDefinition != null && poco.originalPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("originalPortDefinition", poco.originalPortDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedPortConjugator != null && poco.ownedPortConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedPortConjugator", poco.ownedPortConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.conjugatedPortDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.conjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.conjugatedPortDefinition, "conjugatedPortDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.originalPortDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.originalPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.originalPortDefinition, "originalPortDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPortConjugator != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ownedPortConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.ownedPortConjugator, "ownedPortConjugator", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IConjugatedPortDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ConjugatedPortDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.conjugatedPortDefinition != null && poco.conjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "conjugatedPortDefinition", null, poco.conjugatedPortDefinition.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.originalPortDefinition != null && poco.originalPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "originalPortDefinition", null, poco.originalPortDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedPortConjugator != null && poco.ownedPortConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedPortConjugator", null, poco.ownedPortConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.conjugatedPortDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.conjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.conjugatedPortDefinition, "conjugatedPortDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.originalPortDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.originalPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.originalPortDefinition, "originalPortDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPortConjugator != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ownedPortConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.ownedPortConjugator, "ownedPortConjugator", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConjugatedPortTypingWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConjugatedPortTypingWriter.cs new file mode 100644 index 000000000..96ae1b678 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConjugatedPortTypingWriter.cs @@ -0,0 +1,550 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ConjugatedPortTypingWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ConjugatedPortTypingWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IConjugatedPortTyping poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ConjugatedPortTyping"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ConjugatedPortDefinition != null && poco.ConjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("conjugatedPortDefinition", poco.ConjugatedPortDefinition.Id.ToString()); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.portDefinition != null && poco.portDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("portDefinition", poco.portDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.TypedFeature != null && poco.TypedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("typedFeature", poco.TypedFeature.Id.ToString()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.ConjugatedPortDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ConjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.ConjugatedPortDefinition, "conjugatedPortDefinition", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.portDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.portDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.portDefinition, "portDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.TypedFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.TypedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.TypedFeature, "typedFeature", elementOriginMap, currentFileUri); + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IConjugatedPortTyping poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ConjugatedPortTyping"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ConjugatedPortDefinition != null && poco.ConjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "conjugatedPortDefinition", null, poco.ConjugatedPortDefinition.Id.ToString()); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.portDefinition != null && poco.portDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "portDefinition", null, poco.portDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.TypedFeature != null && poco.TypedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "typedFeature", null, poco.TypedFeature.Id.ToString()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.ConjugatedPortDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ConjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.ConjugatedPortDefinition, "conjugatedPortDefinition", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.portDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.portDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.portDefinition, "portDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.TypedFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.TypedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.TypedFeature, "typedFeature", elementOriginMap, currentFileUri); + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConjugationWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConjugationWriter.cs new file mode 100644 index 000000000..493b0ac3c --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConjugationWriter.cs @@ -0,0 +1,510 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ConjugationWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ConjugationWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IConjugation poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Conjugation"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ConjugatedType != null && poco.ConjugatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("conjugatedType", poco.ConjugatedType.Id.ToString()); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.OriginalType != null && poco.OriginalType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("originalType", poco.OriginalType.Id.ToString()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.ConjugatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ConjugatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.ConjugatedType, "conjugatedType", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OriginalType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.OriginalType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.OriginalType, "originalType", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IConjugation poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Conjugation"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ConjugatedType != null && poco.ConjugatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "conjugatedType", null, poco.ConjugatedType.Id.ToString()); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.OriginalType != null && poco.OriginalType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "originalType", null, poco.OriginalType.Id.ToString()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.ConjugatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ConjugatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.ConjugatedType, "conjugatedType", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OriginalType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.OriginalType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.OriginalType, "originalType", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConnectionDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConnectionDefinitionWriter.cs new file mode 100644 index 000000000..c9ff4c792 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConnectionDefinitionWriter.cs @@ -0,0 +1,1923 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ConnectionDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ConnectionDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IConnectionDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ConnectionDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (!poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceType != null && poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceType", poco.sourceType.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectionEnd != null) + { + foreach (var item in poco.connectionEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "connectionEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedType != null) + { + foreach (var item in poco.relatedType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceType, "sourceType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetType != null) + { + foreach (var item in poco.targetType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IConnectionDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ConnectionDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (!poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceType != null && poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceType", null, poco.sourceType.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectionEnd != null) + { + foreach (var item in poco.connectionEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "connectionEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedType != null) + { + foreach (var item in poco.relatedType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceType, "sourceType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetType != null) + { + foreach (var item in poco.targetType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConnectionUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConnectionUsageWriter.cs new file mode 100644 index 000000000..934ee87dc --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConnectionUsageWriter.cs @@ -0,0 +1,2660 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Kernel.Structures; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ConnectionUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ConnectionUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IConnectionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ConnectionUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("defaultFeaturingType", poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceFeature", poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectionDefinition != null) + { + foreach (var item in poco.connectionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "connectionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.partDefinition != null) + { + foreach (var item in poco.partDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "partDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IConnectionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ConnectionUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "defaultFeaturingType", null, poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceFeature", null, poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectionDefinition != null) + { + foreach (var item in poco.connectionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "connectionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.partDefinition != null) + { + foreach (var item in poco.partDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "partDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConnectorWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConnectorWriter.cs new file mode 100644 index 000000000..ac0d7fa21 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConnectorWriter.cs @@ -0,0 +1,1720 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ConnectorWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ConnectorWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IConnector poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Connector"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("defaultFeaturingType", poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceFeature", poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.association != null) + { + foreach (var item in poco.association) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "association", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IConnector poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Connector"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "defaultFeaturingType", null, poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceFeature", null, poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.association != null) + { + foreach (var item in poco.association) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "association", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConstraintDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConstraintDefinitionWriter.cs new file mode 100644 index 000000000..ef46223a7 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConstraintDefinitionWriter.cs @@ -0,0 +1,1914 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ConstraintDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ConstraintDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IConstraintDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ConstraintDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IConstraintDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ConstraintDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConstraintUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConstraintUsageWriter.cs new file mode 100644 index 000000000..1ee39d713 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConstraintUsageWriter.cs @@ -0,0 +1,2539 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ConstraintUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ConstraintUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IConstraintUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ConstraintUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.constraintDefinition != null && poco.constraintDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("constraintDefinition", poco.constraintDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.constraintDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.constraintDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.constraintDefinition, "constraintDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IConstraintUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ConstraintUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.constraintDefinition != null && poco.constraintDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "constraintDefinition", null, poco.constraintDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.constraintDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.constraintDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.constraintDefinition, "constraintDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConstructorExpressionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConstructorExpressionWriter.cs new file mode 100644 index 000000000..4a62d4812 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ConstructorExpressionWriter.cs @@ -0,0 +1,1727 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ConstructorExpressionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ConstructorExpressionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IConstructorExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ConstructorExpression"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("instantiatedType", poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IConstructorExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ConstructorExpression"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "instantiatedType", null, poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CrossSubsettingWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CrossSubsettingWriter.cs new file mode 100644 index 000000000..a6bc60dd7 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/CrossSubsettingWriter.cs @@ -0,0 +1,485 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class CrossSubsettingWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public CrossSubsettingWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ICrossSubsetting poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:CrossSubsetting"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.CrossedFeature != null && poco.CrossedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossedFeature", poco.CrossedFeature.Id.ToString()); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.CrossedFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.CrossedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.CrossedFeature, "crossedFeature", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ICrossSubsetting poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:CrossSubsetting"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.CrossedFeature != null && poco.CrossedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossedFeature", null, poco.CrossedFeature.Id.ToString()); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.CrossedFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.CrossedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.CrossedFeature, "crossedFeature", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DataTypeWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DataTypeWriter.cs new file mode 100644 index 000000000..1685831ad --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DataTypeWriter.cs @@ -0,0 +1,1091 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.DataTypes; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class DataTypeWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public DataTypeWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IDataType poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:DataType"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IDataType poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:DataType"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DecisionNodeWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DecisionNodeWriter.cs new file mode 100644 index 000000000..ea35f4609 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DecisionNodeWriter.cs @@ -0,0 +1,2468 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class DecisionNodeWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public DecisionNodeWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IDecisionNode poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:DecisionNode"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IDecisionNode poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:DecisionNode"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DefinitionWriter.cs new file mode 100644 index 000000000..dac3a8cf1 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DefinitionWriter.cs @@ -0,0 +1,1804 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class DefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public DefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Definition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Definition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DependencyWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DependencyWriter.cs new file mode 100644 index 000000000..9697927d5 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DependencyWriter.cs @@ -0,0 +1,490 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Dependencies; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class DependencyWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public DependencyWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IDependency poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Dependency"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.Client != null) + { + foreach (var item in poco.Client) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "client", elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.Supplier != null) + { + foreach (var item in poco.Supplier) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "supplier", elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IDependency poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Dependency"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.Client != null) + { + foreach (var item in poco.Client) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "client", elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.Supplier != null) + { + foreach (var item in poco.Supplier) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "supplier", elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DifferencingWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DifferencingWriter.cs new file mode 100644 index 000000000..5b6aa50a3 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DifferencingWriter.cs @@ -0,0 +1,484 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class DifferencingWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public DifferencingWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IDifferencing poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Differencing"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.DifferencingType != null && poco.DifferencingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("differencingType", poco.DifferencingType.Id.ToString()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.DifferencingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.DifferencingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.DifferencingType, "differencingType", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IDifferencing poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Differencing"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.DifferencingType != null && poco.DifferencingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "differencingType", null, poco.DifferencingType.Id.ToString()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.DifferencingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.DifferencingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.DifferencingType, "differencingType", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DisjoiningWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DisjoiningWriter.cs new file mode 100644 index 000000000..2e9879780 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DisjoiningWriter.cs @@ -0,0 +1,510 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class DisjoiningWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public DisjoiningWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IDisjoining poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Disjoining"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.DisjoiningType != null && poco.DisjoiningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("disjoiningType", poco.DisjoiningType.Id.ToString()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.TypeDisjoined != null && poco.TypeDisjoined.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("typeDisjoined", poco.TypeDisjoined.Id.ToString()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.DisjoiningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.DisjoiningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.DisjoiningType, "disjoiningType", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.TypeDisjoined != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.TypeDisjoined.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.TypeDisjoined, "typeDisjoined", elementOriginMap, currentFileUri); + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IDisjoining poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Disjoining"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.DisjoiningType != null && poco.DisjoiningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "disjoiningType", null, poco.DisjoiningType.Id.ToString()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.TypeDisjoined != null && poco.TypeDisjoined.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "typeDisjoined", null, poco.TypeDisjoined.Id.ToString()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.DisjoiningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.DisjoiningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.DisjoiningType, "disjoiningType", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.TypeDisjoined != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.TypeDisjoined.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.TypeDisjoined, "typeDisjoined", elementOriginMap, currentFileUri); + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DocumentationWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DocumentationWriter.cs new file mode 100644 index 000000000..a4fa14655 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/DocumentationWriter.cs @@ -0,0 +1,511 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class DocumentationWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public DocumentationWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IDocumentation poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Documentation"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.Body)) + { + xmlWriter.WriteAttributeString("body", poco.Body); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.documentedElement != null && poco.documentedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("documentedElement", poco.documentedElement.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (!string.IsNullOrWhiteSpace(poco.Locale)) + { + xmlWriter.WriteAttributeString("locale", poco.Locale); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotation != null) + { + foreach (var item in poco.annotation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "annotation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.documentedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.documentedElement, "documentedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotatingRelationship != null) + { + foreach (var item in poco.ownedAnnotatingRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotatingRelationship", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IDocumentation poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Documentation"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.Body)) + { + await xmlWriter.WriteAttributeStringAsync(null, "body", null, poco.Body); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.documentedElement != null && poco.documentedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "documentedElement", null, poco.documentedElement.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (!string.IsNullOrWhiteSpace(poco.Locale)) + { + await xmlWriter.WriteAttributeStringAsync(null, "locale", null, poco.Locale); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotation != null) + { + foreach (var item in poco.annotation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "annotation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.documentedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.documentedElement, "documentedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotatingRelationship != null) + { + foreach (var item in poco.ownedAnnotatingRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotatingRelationship", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ElementFilterMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ElementFilterMembershipWriter.cs new file mode 100644 index 000000000..c290127ab --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ElementFilterMembershipWriter.cs @@ -0,0 +1,550 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Packages; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ElementFilterMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ElementFilterMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IElementFilterMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ElementFilterMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.condition != null && poco.condition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("condition", poco.condition.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.condition != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.condition, "condition", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IElementFilterMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ElementFilterMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.condition != null && poco.condition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "condition", null, poco.condition.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.condition != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.condition, "condition", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/EndFeatureMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/EndFeatureMembershipWriter.cs new file mode 100644 index 000000000..15ac12f49 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/EndFeatureMembershipWriter.cs @@ -0,0 +1,550 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class EndFeatureMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public EndFeatureMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IEndFeatureMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:EndFeatureMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedMemberFeature != null && poco.ownedMemberFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedMemberFeature", poco.ownedMemberFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMemberFeature != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedMemberFeature, "ownedMemberFeature", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IEndFeatureMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:EndFeatureMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedMemberFeature != null && poco.ownedMemberFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberFeature", null, poco.ownedMemberFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMemberFeature != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedMemberFeature, "ownedMemberFeature", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/EnumerationDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/EnumerationDefinitionWriter.cs new file mode 100644 index 000000000..d6b743634 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/EnumerationDefinitionWriter.cs @@ -0,0 +1,1804 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class EnumerationDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public EnumerationDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IEnumerationDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:EnumerationDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "false"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.enumeratedValue != null) + { + foreach (var item in poco.enumeratedValue) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "enumeratedValue", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IEnumerationDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:EnumerationDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "false"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.enumeratedValue != null) + { + foreach (var item in poco.enumeratedValue) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "enumeratedValue", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/EnumerationUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/EnumerationUsageWriter.cs new file mode 100644 index 000000000..24a414510 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/EnumerationUsageWriter.cs @@ -0,0 +1,2402 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.DataTypes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class EnumerationUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public EnumerationUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IEnumerationUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:EnumerationUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.enumerationDefinition != null && poco.enumerationDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("enumerationDefinition", poco.enumerationDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "false"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.enumerationDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.enumerationDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.enumerationDefinition, "enumerationDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IEnumerationUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:EnumerationUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.enumerationDefinition != null && poco.enumerationDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "enumerationDefinition", null, poco.enumerationDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "false"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.enumerationDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.enumerationDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.enumerationDefinition, "enumerationDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/EventOccurrenceUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/EventOccurrenceUsageWriter.cs new file mode 100644 index 000000000..09bfe12ea --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/EventOccurrenceUsageWriter.cs @@ -0,0 +1,2483 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class EventOccurrenceUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public EventOccurrenceUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IEventOccurrenceUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:EventOccurrenceUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.eventOccurrence != null && poco.eventOccurrence.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("eventOccurrence", poco.eventOccurrence.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "false"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.eventOccurrence != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.eventOccurrence.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.eventOccurrence, "eventOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IEventOccurrenceUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:EventOccurrenceUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.eventOccurrence != null && poco.eventOccurrence.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "eventOccurrence", null, poco.eventOccurrence.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "false"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.eventOccurrence != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.eventOccurrence.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.eventOccurrence, "eventOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ExhibitStateUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ExhibitStateUsageWriter.cs new file mode 100644 index 000000000..4cb1c0547 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ExhibitStateUsageWriter.cs @@ -0,0 +1,2630 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ExhibitStateUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ExhibitStateUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IExhibitStateUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ExhibitStateUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.doAction != null && poco.doAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("doAction", poco.doAction.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.entryAction != null && poco.entryAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("entryAction", poco.entryAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.exhibitedState != null && poco.exhibitedState.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("exhibitedState", poco.exhibitedState.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.exitAction != null && poco.exitAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("exitAction", poco.exitAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsParallel) + { + xmlWriter.WriteAttributeString("isParallel", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "false"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.doAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.doAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.doAction, "doAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.entryAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.entryAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.entryAction, "entryAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.exhibitedState != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.exhibitedState.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.exhibitedState, "exhibitedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.exitAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.exitAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.exitAction, "exitAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stateDefinition != null) + { + foreach (var item in poco.stateDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "stateDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IExhibitStateUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ExhibitStateUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.doAction != null && poco.doAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "doAction", null, poco.doAction.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.entryAction != null && poco.entryAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "entryAction", null, poco.entryAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.exhibitedState != null && poco.exhibitedState.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "exhibitedState", null, poco.exhibitedState.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.exitAction != null && poco.exitAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "exitAction", null, poco.exitAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsParallel) + { + await xmlWriter.WriteAttributeStringAsync(null, "isParallel", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "false"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.doAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.doAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.doAction, "doAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.entryAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.entryAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.entryAction, "entryAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.exhibitedState != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.exhibitedState.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.exhibitedState, "exhibitedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.exitAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.exitAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.exitAction, "exitAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stateDefinition != null) + { + foreach (var item in poco.stateDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "stateDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ExpressionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ExpressionWriter.cs new file mode 100644 index 000000000..82ed3aa55 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ExpressionWriter.cs @@ -0,0 +1,1666 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ExpressionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ExpressionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Expression"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Expression"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureChainExpressionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureChainExpressionWriter.cs new file mode 100644 index 000000000..551369a20 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureChainExpressionWriter.cs @@ -0,0 +1,1781 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class FeatureChainExpressionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public FeatureChainExpressionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IFeatureChainExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:FeatureChainExpression"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("instantiatedType", poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (poco.Operator != ".") + { + if (!string.IsNullOrWhiteSpace(poco.Operator)) + { + xmlWriter.WriteAttributeString("operator", poco.Operator); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.targetFeature != null && poco.targetFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("targetFeature", poco.targetFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.targetFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.targetFeature, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IFeatureChainExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:FeatureChainExpression"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "instantiatedType", null, poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (poco.Operator != ".") + { + if (!string.IsNullOrWhiteSpace(poco.Operator)) + { + await xmlWriter.WriteAttributeStringAsync(null, "operator", null, poco.Operator); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.targetFeature != null && poco.targetFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "targetFeature", null, poco.targetFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.targetFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.targetFeature, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureChainingWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureChainingWriter.cs new file mode 100644 index 000000000..a4ef26bc5 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureChainingWriter.cs @@ -0,0 +1,484 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class FeatureChainingWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public FeatureChainingWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IFeatureChaining poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:FeatureChaining"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ChainingFeature != null && poco.ChainingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("chainingFeature", poco.ChainingFeature.Id.ToString()); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.ChainingFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ChainingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.ChainingFeature, "chainingFeature", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IFeatureChaining poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:FeatureChaining"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ChainingFeature != null && poco.ChainingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "chainingFeature", null, poco.ChainingFeature.Id.ToString()); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (poco.ChainingFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ChainingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.ChainingFeature, "chainingFeature", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureInvertingWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureInvertingWriter.cs new file mode 100644 index 000000000..6369eae14 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureInvertingWriter.cs @@ -0,0 +1,510 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class FeatureInvertingWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public FeatureInvertingWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IFeatureInverting poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:FeatureInverting"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.FeatureInverted != null && poco.FeatureInverted.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureInverted", poco.FeatureInverted.Id.ToString()); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.InvertingFeature != null && poco.InvertingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("invertingFeature", poco.InvertingFeature.Id.ToString()); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.FeatureInverted != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.FeatureInverted.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.FeatureInverted, "featureInverted", elementOriginMap, currentFileUri); + } + } + + if (poco.InvertingFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.InvertingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.InvertingFeature, "invertingFeature", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IFeatureInverting poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:FeatureInverting"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.FeatureInverted != null && poco.FeatureInverted.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureInverted", null, poco.FeatureInverted.Id.ToString()); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.InvertingFeature != null && poco.InvertingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "invertingFeature", null, poco.InvertingFeature.Id.ToString()); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.FeatureInverted != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.FeatureInverted.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.FeatureInverted, "featureInverted", elementOriginMap, currentFileUri); + } + } + + if (poco.InvertingFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.InvertingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.InvertingFeature, "invertingFeature", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureMembershipWriter.cs new file mode 100644 index 000000000..e824056d9 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureMembershipWriter.cs @@ -0,0 +1,550 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class FeatureMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public FeatureMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IFeatureMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:FeatureMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedMemberFeature != null && poco.ownedMemberFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedMemberFeature", poco.ownedMemberFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMemberFeature != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedMemberFeature, "ownedMemberFeature", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IFeatureMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:FeatureMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedMemberFeature != null && poco.ownedMemberFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberFeature", null, poco.ownedMemberFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMemberFeature != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedMemberFeature, "ownedMemberFeature", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureReferenceExpressionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureReferenceExpressionWriter.cs new file mode 100644 index 000000000..2a9790955 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureReferenceExpressionWriter.cs @@ -0,0 +1,1705 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class FeatureReferenceExpressionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public FeatureReferenceExpressionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IFeatureReferenceExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:FeatureReferenceExpression"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.referent != null && poco.referent.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("referent", poco.referent.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.referent != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.referent.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.referent, "referent", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IFeatureReferenceExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:FeatureReferenceExpression"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.referent != null && poco.referent.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "referent", null, poco.referent.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.referent != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.referent.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.referent, "referent", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureTypingWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureTypingWriter.cs new file mode 100644 index 000000000..6e6f394bf --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureTypingWriter.cs @@ -0,0 +1,511 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class FeatureTypingWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public FeatureTypingWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IFeatureTyping poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:FeatureTyping"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.Type != null && poco.Type.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("type", poco.Type.Id.ToString()); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.TypedFeature != null && poco.TypedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("typedFeature", poco.TypedFeature.Id.ToString()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.Type != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.Type.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.Type, "type", elementOriginMap, currentFileUri); + } + } + + if (poco.TypedFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.TypedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.TypedFeature, "typedFeature", elementOriginMap, currentFileUri); + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IFeatureTyping poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:FeatureTyping"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.Type != null && poco.Type.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "type", null, poco.Type.Id.ToString()); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.TypedFeature != null && poco.TypedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "typedFeature", null, poco.TypedFeature.Id.ToString()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.Type != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.Type.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.Type, "type", elementOriginMap, currentFileUri); + } + } + + if (poco.TypedFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.TypedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.TypedFeature, "typedFeature", elementOriginMap, currentFileUri); + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureValueWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureValueWriter.cs new file mode 100644 index 000000000..4d86f8e15 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureValueWriter.cs @@ -0,0 +1,609 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.FeatureValues; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class FeatureValueWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public FeatureValueWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IFeatureValue poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:FeatureValue"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureWithValue != null && poco.featureWithValue.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureWithValue", poco.featureWithValue.Id.ToString()); + } + } + + if (poco.IsDefault) + { + xmlWriter.WriteAttributeString("isDefault", "true"); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsInitial) + { + xmlWriter.WriteAttributeString("isInitial", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.value != null && poco.value.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("value", poco.value.Id.ToString()); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureWithValue != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureWithValue.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureWithValue, "featureWithValue", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.value != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.value, "value", writerOptions, elementOriginMap, currentFileUri); + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IFeatureValue poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:FeatureValue"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureWithValue != null && poco.featureWithValue.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureWithValue", null, poco.featureWithValue.Id.ToString()); + } + } + + if (poco.IsDefault) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDefault", null, "true"); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsInitial) + { + await xmlWriter.WriteAttributeStringAsync(null, "isInitial", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.value != null && poco.value.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "value", null, poco.value.Id.ToString()); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureWithValue != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureWithValue.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureWithValue, "featureWithValue", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.value != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.value, "value", writerOptions, elementOriginMap, currentFileUri); + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureWriter.cs new file mode 100644 index 000000000..3d267b4fc --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FeatureWriter.cs @@ -0,0 +1,1572 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class FeatureWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public FeatureWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IFeature poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Feature"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IFeature poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Feature"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FlowDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FlowDefinitionWriter.cs new file mode 100644 index 000000000..4297a7c3d --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FlowDefinitionWriter.cs @@ -0,0 +1,1969 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Interactions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class FlowDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public FlowDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IFlowDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:FlowDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceType != null && poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceType", poco.sourceType.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.flowEnd != null) + { + foreach (var item in poco.flowEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "flowEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedType != null) + { + foreach (var item in poco.relatedType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceType, "sourceType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetType != null) + { + foreach (var item in poco.targetType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IFlowDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:FlowDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceType != null && poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceType", null, poco.sourceType.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.flowEnd != null) + { + foreach (var item in poco.flowEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "flowEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedType != null) + { + foreach (var item in poco.relatedType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceType, "sourceType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetType != null) + { + foreach (var item in poco.targetType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FlowEndWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FlowEndWriter.cs new file mode 100644 index 000000000..98d23f712 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FlowEndWriter.cs @@ -0,0 +1,1573 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Interactions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class FlowEndWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public FlowEndWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IFlowEnd poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:FlowEnd"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IFlowEnd poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:FlowEnd"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FlowUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FlowUsageWriter.cs new file mode 100644 index 000000000..4f7d999c8 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FlowUsageWriter.cs @@ -0,0 +1,2797 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Kernel.Interactions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class FlowUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public FlowUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IFlowUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:FlowUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("defaultFeaturingType", poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.payloadFeature != null && poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("payloadFeature", poco.payloadFeature.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceFeature", poco.sourceFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceOutputFeature != null && poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceOutputFeature", poco.sourceOutputFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.targetInputFeature != null && poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("targetInputFeature", poco.targetInputFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.flowDefinition != null) + { + foreach (var item in poco.flowDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "flowDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.flowEnd != null) + { + foreach (var item in poco.flowEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "flowEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.payloadFeature, "payloadFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadType != null) + { + foreach (var item in poco.payloadType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "payloadType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceOutputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceOutputFeature, "sourceOutputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetInputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.targetInputFeature, "targetInputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IFlowUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:FlowUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "defaultFeaturingType", null, poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.payloadFeature != null && poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "payloadFeature", null, poco.payloadFeature.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceFeature", null, poco.sourceFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceOutputFeature != null && poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceOutputFeature", null, poco.sourceOutputFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.targetInputFeature != null && poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "targetInputFeature", null, poco.targetInputFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.flowDefinition != null) + { + foreach (var item in poco.flowDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "flowDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.flowEnd != null) + { + foreach (var item in poco.flowEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "flowEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.payloadFeature, "payloadFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadType != null) + { + foreach (var item in poco.payloadType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "payloadType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceOutputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceOutputFeature, "sourceOutputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetInputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.targetInputFeature, "targetInputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FlowWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FlowWriter.cs new file mode 100644 index 000000000..f83758cf9 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FlowWriter.cs @@ -0,0 +1,1881 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Interactions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class FlowWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public FlowWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IFlow poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Flow"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("defaultFeaturingType", poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.payloadFeature != null && poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("payloadFeature", poco.payloadFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceFeature", poco.sourceFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceOutputFeature != null && poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceOutputFeature", poco.sourceOutputFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.targetInputFeature != null && poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("targetInputFeature", poco.targetInputFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.flowEnd != null) + { + foreach (var item in poco.flowEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "flowEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.interaction != null) + { + foreach (var item in poco.interaction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "interaction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.payloadFeature, "payloadFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadType != null) + { + foreach (var item in poco.payloadType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "payloadType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceOutputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceOutputFeature, "sourceOutputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetInputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.targetInputFeature, "targetInputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IFlow poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Flow"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "defaultFeaturingType", null, poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.payloadFeature != null && poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "payloadFeature", null, poco.payloadFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceFeature", null, poco.sourceFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceOutputFeature != null && poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceOutputFeature", null, poco.sourceOutputFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.targetInputFeature != null && poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "targetInputFeature", null, poco.targetInputFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.flowEnd != null) + { + foreach (var item in poco.flowEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "flowEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.interaction != null) + { + foreach (var item in poco.interaction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "interaction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.payloadFeature, "payloadFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadType != null) + { + foreach (var item in poco.payloadType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "payloadType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceOutputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceOutputFeature, "sourceOutputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetInputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.targetInputFeature, "targetInputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ForLoopActionUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ForLoopActionUsageWriter.cs new file mode 100644 index 000000000..a6c3ca649 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ForLoopActionUsageWriter.cs @@ -0,0 +1,2583 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ForLoopActionUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ForLoopActionUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IForLoopActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ForLoopActionUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.bodyAction != null && poco.bodyAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("bodyAction", poco.bodyAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.loopVariable != null && poco.loopVariable.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("loopVariable", poco.loopVariable.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.seqArgument != null && poco.seqArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("seqArgument", poco.seqArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.bodyAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.bodyAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.bodyAction, "bodyAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.loopVariable != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.loopVariable.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.loopVariable, "loopVariable", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.seqArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.seqArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.seqArgument, "seqArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IForLoopActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ForLoopActionUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.bodyAction != null && poco.bodyAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "bodyAction", null, poco.bodyAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.loopVariable != null && poco.loopVariable.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "loopVariable", null, poco.loopVariable.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.seqArgument != null && poco.seqArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "seqArgument", null, poco.seqArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.bodyAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.bodyAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.bodyAction, "bodyAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.loopVariable != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.loopVariable.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.loopVariable, "loopVariable", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.seqArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.seqArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.seqArgument, "seqArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ForkNodeWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ForkNodeWriter.cs new file mode 100644 index 000000000..9fab02c53 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ForkNodeWriter.cs @@ -0,0 +1,2468 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ForkNodeWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ForkNodeWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IForkNode poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ForkNode"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IForkNode poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ForkNode"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FramedConcernMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FramedConcernMembershipWriter.cs new file mode 100644 index 000000000..bffce5074 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FramedConcernMembershipWriter.cs @@ -0,0 +1,601 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.Systems.Requirements; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class FramedConcernMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public FramedConcernMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IFramedConcernMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:FramedConcernMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.Kind != RequirementConstraintKind.Requirement) + { + xmlWriter.WriteAttributeString("kind", poco.Kind.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConcern != null && poco.ownedConcern.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConcern", poco.ownedConcern.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.referencedConcern != null && poco.referencedConcern.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("referencedConcern", poco.referencedConcern.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConcern, "ownedConcern", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.referencedConcern != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.referencedConcern.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.referencedConcern, "referencedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IFramedConcernMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:FramedConcernMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.Kind != RequirementConstraintKind.Requirement) + { + await xmlWriter.WriteAttributeStringAsync(null, "kind", null, poco.Kind.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConcern != null && poco.ownedConcern.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConcern", null, poco.ownedConcern.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.referencedConcern != null && poco.referencedConcern.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "referencedConcern", null, poco.referencedConcern.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConcern, "ownedConcern", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.referencedConcern != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.referencedConcern.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.referencedConcern, "referencedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FunctionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FunctionWriter.cs new file mode 100644 index 000000000..44efab7a1 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/FunctionWriter.cs @@ -0,0 +1,1190 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class FunctionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public FunctionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IFunction poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Function"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IFunction poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Function"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/IfActionUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/IfActionUsageWriter.cs new file mode 100644 index 000000000..e9c85afcf --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/IfActionUsageWriter.cs @@ -0,0 +1,2583 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class IfActionUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public IfActionUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IIfActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:IfActionUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.elseAction != null && poco.elseAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("elseAction", poco.elseAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ifArgument != null && poco.ifArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ifArgument", poco.ifArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.thenAction != null && poco.thenAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("thenAction", poco.thenAction.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.elseAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.elseAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.elseAction, "elseAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ifArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ifArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.ifArgument, "ifArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.thenAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.thenAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.thenAction, "thenAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IIfActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:IfActionUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.elseAction != null && poco.elseAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elseAction", null, poco.elseAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ifArgument != null && poco.ifArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ifArgument", null, poco.ifArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.thenAction != null && poco.thenAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "thenAction", null, poco.thenAction.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.elseAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.elseAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.elseAction, "elseAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ifArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ifArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.ifArgument, "ifArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.thenAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.thenAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.thenAction, "thenAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/IncludeUseCaseUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/IncludeUseCaseUsageWriter.cs new file mode 100644 index 000000000..76f9ba992 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/IncludeUseCaseUsageWriter.cs @@ -0,0 +1,2719 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class IncludeUseCaseUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public IncludeUseCaseUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IIncludeUseCaseUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:IncludeUseCaseUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "false"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("objectiveRequirement", poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.useCaseDefinition != null && poco.useCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("useCaseDefinition", poco.useCaseDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.useCaseIncluded != null && poco.useCaseIncluded.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("useCaseIncluded", poco.useCaseIncluded.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.includedUseCase != null) + { + foreach (var item in poco.includedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "includedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.useCaseDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.useCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.useCaseDefinition, "useCaseDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.useCaseIncluded != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.useCaseIncluded.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.useCaseIncluded, "useCaseIncluded", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IIncludeUseCaseUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:IncludeUseCaseUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "false"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "objectiveRequirement", null, poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.useCaseDefinition != null && poco.useCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "useCaseDefinition", null, poco.useCaseDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.useCaseIncluded != null && poco.useCaseIncluded.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "useCaseIncluded", null, poco.useCaseIncluded.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.includedUseCase != null) + { + foreach (var item in poco.includedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "includedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.useCaseDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.useCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.useCaseDefinition, "useCaseDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.useCaseIncluded != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.useCaseIncluded.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.useCaseIncluded, "useCaseIncluded", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/IndexExpressionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/IndexExpressionWriter.cs new file mode 100644 index 000000000..561047666 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/IndexExpressionWriter.cs @@ -0,0 +1,1743 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class IndexExpressionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public IndexExpressionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IIndexExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:IndexExpression"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("instantiatedType", poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (poco.Operator != "#") + { + if (!string.IsNullOrWhiteSpace(poco.Operator)) + { + xmlWriter.WriteAttributeString("operator", poco.Operator); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IIndexExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:IndexExpression"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "instantiatedType", null, poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (poco.Operator != "#") + { + if (!string.IsNullOrWhiteSpace(poco.Operator)) + { + await xmlWriter.WriteAttributeStringAsync(null, "operator", null, poco.Operator); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/InteractionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/InteractionWriter.cs new file mode 100644 index 000000000..777622674 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/InteractionWriter.cs @@ -0,0 +1,1223 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Interactions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class InteractionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public InteractionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IInteraction poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Interaction"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceType != null && poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceType", poco.sourceType.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.associationEnd != null) + { + foreach (var item in poco.associationEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "associationEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedType != null) + { + foreach (var item in poco.relatedType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceType, "sourceType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetType != null) + { + foreach (var item in poco.targetType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IInteraction poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Interaction"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceType != null && poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceType", null, poco.sourceType.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.associationEnd != null) + { + foreach (var item in poco.associationEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "associationEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedType != null) + { + foreach (var item in poco.relatedType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceType, "sourceType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetType != null) + { + foreach (var item in poco.targetType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/InterfaceDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/InterfaceDefinitionWriter.cs new file mode 100644 index 000000000..10bf91e58 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/InterfaceDefinitionWriter.cs @@ -0,0 +1,1923 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class InterfaceDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public InterfaceDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IInterfaceDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:InterfaceDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (!poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceType != null && poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceType", poco.sourceType.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.interfaceEnd != null) + { + foreach (var item in poco.interfaceEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "interfaceEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedType != null) + { + foreach (var item in poco.relatedType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceType, "sourceType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetType != null) + { + foreach (var item in poco.targetType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IInterfaceDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:InterfaceDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (!poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceType != null && poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceType", null, poco.sourceType.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.interfaceEnd != null) + { + foreach (var item in poco.interfaceEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "interfaceEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedType != null) + { + foreach (var item in poco.relatedType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceType, "sourceType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetType != null) + { + foreach (var item in poco.targetType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/InterfaceUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/InterfaceUsageWriter.cs new file mode 100644 index 000000000..a8d5913bf --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/InterfaceUsageWriter.cs @@ -0,0 +1,2660 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Kernel.Structures; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class InterfaceUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public InterfaceUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IInterfaceUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:InterfaceUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("defaultFeaturingType", poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceFeature", poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.interfaceDefinition != null) + { + foreach (var item in poco.interfaceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "interfaceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.partDefinition != null) + { + foreach (var item in poco.partDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "partDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IInterfaceUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:InterfaceUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "defaultFeaturingType", null, poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceFeature", null, poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.interfaceDefinition != null) + { + foreach (var item in poco.interfaceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "interfaceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.partDefinition != null) + { + foreach (var item in poco.partDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "partDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/IntersectingWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/IntersectingWriter.cs new file mode 100644 index 000000000..520de01ae --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/IntersectingWriter.cs @@ -0,0 +1,484 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class IntersectingWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public IntersectingWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IIntersecting poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Intersecting"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.IntersectingType != null && poco.IntersectingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("intersectingType", poco.IntersectingType.Id.ToString()); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.IntersectingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.IntersectingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.IntersectingType, "intersectingType", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IIntersecting poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Intersecting"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.IntersectingType != null && poco.IntersectingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "intersectingType", null, poco.IntersectingType.Id.ToString()); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.IntersectingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.IntersectingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.IntersectingType, "intersectingType", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/InvariantWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/InvariantWriter.cs new file mode 100644 index 000000000..5af1646e2 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/InvariantWriter.cs @@ -0,0 +1,1676 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class InvariantWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public InvariantWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IInvariant poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Invariant"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsNegated) + { + xmlWriter.WriteAttributeString("isNegated", "true"); + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.predicate != null && poco.predicate.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("predicate", poco.predicate.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.predicate != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.predicate.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.predicate, "predicate", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IInvariant poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Invariant"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsNegated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isNegated", null, "true"); + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.predicate != null && poco.predicate.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "predicate", null, poco.predicate.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.predicate != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.predicate.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.predicate, "predicate", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/InvocationExpressionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/InvocationExpressionWriter.cs new file mode 100644 index 000000000..21e91e408 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/InvocationExpressionWriter.cs @@ -0,0 +1,1727 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class InvocationExpressionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public InvocationExpressionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IInvocationExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:InvocationExpression"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("instantiatedType", poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IInvocationExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:InvocationExpression"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "instantiatedType", null, poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ItemDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ItemDefinitionWriter.cs new file mode 100644 index 000000000..1747dc6d0 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ItemDefinitionWriter.cs @@ -0,0 +1,1815 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Structures; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ItemDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ItemDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IItemDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ItemDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IItemDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ItemDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ItemUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ItemUsageWriter.cs new file mode 100644 index 000000000..2be0f2f54 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ItemUsageWriter.cs @@ -0,0 +1,2468 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Structures; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ItemUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ItemUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IItemUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ItemUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IItemUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ItemUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/JoinNodeWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/JoinNodeWriter.cs new file mode 100644 index 000000000..80054946c --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/JoinNodeWriter.cs @@ -0,0 +1,2468 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class JoinNodeWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public JoinNodeWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IJoinNode poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:JoinNode"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IJoinNode poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:JoinNode"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LibraryPackageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LibraryPackageWriter.cs new file mode 100644 index 000000000..e97ab4e72 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LibraryPackageWriter.cs @@ -0,0 +1,575 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Packages; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class LibraryPackageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public LibraryPackageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ILibraryPackage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:LibraryPackage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsStandard) + { + xmlWriter.WriteAttributeString("isStandard", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.filterCondition != null) + { + foreach (var item in poco.filterCondition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "filterCondition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ILibraryPackage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:LibraryPackage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsStandard) + { + await xmlWriter.WriteAttributeStringAsync(null, "isStandard", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.filterCondition != null) + { + foreach (var item in poco.filterCondition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "filterCondition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralBooleanWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralBooleanWriter.cs new file mode 100644 index 000000000..bf4f187d3 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralBooleanWriter.cs @@ -0,0 +1,1677 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class LiteralBooleanWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public LiteralBooleanWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ILiteralBoolean poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:LiteralBoolean"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Value) + { + xmlWriter.WriteAttributeString("value", "true"); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ILiteralBoolean poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:LiteralBoolean"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Value) + { + await xmlWriter.WriteAttributeStringAsync(null, "value", null, "true"); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralExpressionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralExpressionWriter.cs new file mode 100644 index 000000000..98ae34812 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralExpressionWriter.cs @@ -0,0 +1,1667 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class LiteralExpressionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public LiteralExpressionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ILiteralExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:LiteralExpression"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ILiteralExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:LiteralExpression"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralInfinityWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralInfinityWriter.cs new file mode 100644 index 000000000..2b558201f --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralInfinityWriter.cs @@ -0,0 +1,1667 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class LiteralInfinityWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public LiteralInfinityWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ILiteralInfinity poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:LiteralInfinity"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ILiteralInfinity poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:LiteralInfinity"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralIntegerWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralIntegerWriter.cs new file mode 100644 index 000000000..f6abcf1c5 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralIntegerWriter.cs @@ -0,0 +1,1671 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class LiteralIntegerWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public LiteralIntegerWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ILiteralInteger poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:LiteralInteger"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + xmlWriter.WriteAttributeString("value", poco.Value.ToString(CultureInfo.InvariantCulture)); + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ILiteralInteger poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:LiteralInteger"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + await xmlWriter.WriteAttributeStringAsync(null, "value", null, poco.Value.ToString(CultureInfo.InvariantCulture)); + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralRationalWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralRationalWriter.cs new file mode 100644 index 000000000..00cfe9664 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralRationalWriter.cs @@ -0,0 +1,1671 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class LiteralRationalWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public LiteralRationalWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ILiteralRational poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:LiteralRational"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + xmlWriter.WriteAttributeString("value", poco.Value.ToString(CultureInfo.InvariantCulture)); + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ILiteralRational poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:LiteralRational"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + await xmlWriter.WriteAttributeStringAsync(null, "value", null, poco.Value.ToString(CultureInfo.InvariantCulture)); + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralStringWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralStringWriter.cs new file mode 100644 index 000000000..4e0b90af7 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/LiteralStringWriter.cs @@ -0,0 +1,1677 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class LiteralStringWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public LiteralStringWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ILiteralString poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:LiteralString"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.Value)) + { + xmlWriter.WriteAttributeString("value", poco.Value); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ILiteralString poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:LiteralString"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.Value)) + { + await xmlWriter.WriteAttributeStringAsync(null, "value", null, poco.Value); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MembershipExposeWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MembershipExposeWriter.cs new file mode 100644 index 000000000..6bf021190 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MembershipExposeWriter.cs @@ -0,0 +1,553 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class MembershipExposeWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public MembershipExposeWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IMembershipExpose poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:MembershipExpose"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.importedElement != null && poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("importedElement", poco.importedElement.Id.ToString()); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ImportedMembership != null && poco.ImportedMembership.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("importedMembership", poco.ImportedMembership.Id.ToString()); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (!poco.IsImportAll) + { + xmlWriter.WriteAttributeString("isImportAll", "false"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsRecursive) + { + xmlWriter.WriteAttributeString("isRecursive", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Protected) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.importedElement, "importedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.ImportedMembership != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ImportedMembership.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.ImportedMembership, "importedMembership", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IMembershipExpose poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:MembershipExpose"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.importedElement != null && poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "importedElement", null, poco.importedElement.Id.ToString()); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ImportedMembership != null && poco.ImportedMembership.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "importedMembership", null, poco.ImportedMembership.Id.ToString()); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (!poco.IsImportAll) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImportAll", null, "false"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsRecursive) + { + await xmlWriter.WriteAttributeStringAsync(null, "isRecursive", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Protected) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.importedElement, "importedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.ImportedMembership != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ImportedMembership.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.ImportedMembership, "importedMembership", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MembershipImportWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MembershipImportWriter.cs new file mode 100644 index 000000000..2700a7cc0 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MembershipImportWriter.cs @@ -0,0 +1,552 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class MembershipImportWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public MembershipImportWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IMembershipImport poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:MembershipImport"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.importedElement != null && poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("importedElement", poco.importedElement.Id.ToString()); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ImportedMembership != null && poco.ImportedMembership.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("importedMembership", poco.ImportedMembership.Id.ToString()); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsImportAll) + { + xmlWriter.WriteAttributeString("isImportAll", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsRecursive) + { + xmlWriter.WriteAttributeString("isRecursive", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Private) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.importedElement, "importedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.ImportedMembership != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ImportedMembership.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.ImportedMembership, "importedMembership", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IMembershipImport poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:MembershipImport"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.importedElement != null && poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "importedElement", null, poco.importedElement.Id.ToString()); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ImportedMembership != null && poco.ImportedMembership.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "importedMembership", null, poco.ImportedMembership.Id.ToString()); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsImportAll) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImportAll", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsRecursive) + { + await xmlWriter.WriteAttributeStringAsync(null, "isRecursive", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Private) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.importedElement, "importedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.ImportedMembership != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ImportedMembership.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.ImportedMembership, "importedMembership", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MembershipWriter.cs new file mode 100644 index 000000000..ff65c9f0e --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MembershipWriter.cs @@ -0,0 +1,530 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class MembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public MembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Membership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.MemberElement != null && poco.MemberElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("memberElement", poco.MemberElement.Id.ToString()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.memberElementId)) + { + xmlWriter.WriteAttributeString("memberElementId", poco.memberElementId); + } + } + + if (!string.IsNullOrWhiteSpace(poco.MemberName)) + { + xmlWriter.WriteAttributeString("memberName", poco.MemberName); + } + + if (!string.IsNullOrWhiteSpace(poco.MemberShortName)) + { + xmlWriter.WriteAttributeString("memberShortName", poco.MemberShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.MemberElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.MemberElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.MemberElement, "memberElement", elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Membership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.MemberElement != null && poco.MemberElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "memberElement", null, poco.MemberElement.Id.ToString()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.memberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "memberElementId", null, poco.memberElementId); + } + } + + if (!string.IsNullOrWhiteSpace(poco.MemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "memberName", null, poco.MemberName); + } + + if (!string.IsNullOrWhiteSpace(poco.MemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "memberShortName", null, poco.MemberShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.MemberElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.MemberElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.MemberElement, "memberElement", elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MergeNodeWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MergeNodeWriter.cs new file mode 100644 index 000000000..7ace31e4b --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MergeNodeWriter.cs @@ -0,0 +1,2468 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class MergeNodeWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public MergeNodeWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IMergeNode poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:MergeNode"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IMergeNode poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:MergeNode"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MetaclassWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MetaclassWriter.cs new file mode 100644 index 000000000..7128f6854 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MetaclassWriter.cs @@ -0,0 +1,1092 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Structures; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Metadata; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class MetaclassWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public MetaclassWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IMetaclass poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Metaclass"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IMetaclass poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Metaclass"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MetadataAccessExpressionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MetadataAccessExpressionWriter.cs new file mode 100644 index 000000000..cef6a1ac1 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MetadataAccessExpressionWriter.cs @@ -0,0 +1,1705 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class MetadataAccessExpressionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public MetadataAccessExpressionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IMetadataAccessExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:MetadataAccessExpression"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.referencedElement != null && poco.referencedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("referencedElement", poco.referencedElement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.referencedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.referencedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.referencedElement, "referencedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IMetadataAccessExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:MetadataAccessExpression"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.referencedElement != null && poco.referencedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "referencedElement", null, poco.referencedElement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.referencedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.referencedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.referencedElement, "referencedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MetadataDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MetadataDefinitionWriter.cs new file mode 100644 index 000000000..17ec89c47 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MetadataDefinitionWriter.cs @@ -0,0 +1,1815 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Metadata; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class MetadataDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public MetadataDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IMetadataDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:MetadataDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IMetadataDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:MetadataDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MetadataFeatureWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MetadataFeatureWriter.cs new file mode 100644 index 000000000..b5464eaed --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MetadataFeatureWriter.cs @@ -0,0 +1,1677 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Metadata; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class MetadataFeatureWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public MetadataFeatureWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IMetadataFeature poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:MetadataFeature"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.metaclass != null && poco.metaclass.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("metaclass", poco.metaclass.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotatedElement != null) + { + foreach (var item in poco.annotatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "annotatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotation != null) + { + foreach (var item in poco.annotation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "annotation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.metaclass != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.metaclass.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.metaclass, "metaclass", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotatingRelationship != null) + { + foreach (var item in poco.ownedAnnotatingRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotatingRelationship", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IMetadataFeature poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:MetadataFeature"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.metaclass != null && poco.metaclass.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "metaclass", null, poco.metaclass.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotatedElement != null) + { + foreach (var item in poco.annotatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "annotatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotation != null) + { + foreach (var item in poco.annotation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "annotation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.metaclass != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.metaclass.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.metaclass, "metaclass", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotatingRelationship != null) + { + foreach (var item in poco.ownedAnnotatingRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotatingRelationship", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MetadataUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MetadataUsageWriter.cs new file mode 100644 index 000000000..782ee2c88 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MetadataUsageWriter.cs @@ -0,0 +1,2573 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Metadata; + using SysML2.NET.Core.POCO.Kernel.Structures; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class MetadataUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public MetadataUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IMetadataUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:MetadataUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.metadataDefinition != null && poco.metadataDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("metadataDefinition", poco.metadataDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotatedElement != null) + { + foreach (var item in poco.annotatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "annotatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotation != null) + { + foreach (var item in poco.annotation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "annotation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.metadataDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.metadataDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.metadataDefinition, "metadataDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotatingRelationship != null) + { + foreach (var item in poco.ownedAnnotatingRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotatingRelationship", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IMetadataUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:MetadataUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.metadataDefinition != null && poco.metadataDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "metadataDefinition", null, poco.metadataDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotatedElement != null) + { + foreach (var item in poco.annotatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "annotatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotation != null) + { + foreach (var item in poco.annotation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "annotation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.metadataDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.metadataDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.metadataDefinition, "metadataDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotatingRelationship != null) + { + foreach (var item in poco.ownedAnnotatingRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotatingRelationship", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MultiplicityRangeWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MultiplicityRangeWriter.cs new file mode 100644 index 000000000..e6ce00fc7 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MultiplicityRangeWriter.cs @@ -0,0 +1,1672 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Multiplicities; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class MultiplicityRangeWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public MultiplicityRangeWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IMultiplicityRange poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:MultiplicityRange"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.lowerBound != null && poco.lowerBound.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("lowerBound", poco.lowerBound.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.upperBound != null && poco.upperBound.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("upperBound", poco.upperBound.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.bound != null) + { + foreach (var item in poco.bound) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "bound", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.lowerBound != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.lowerBound.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.lowerBound, "lowerBound", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.upperBound != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.upperBound.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.upperBound, "upperBound", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IMultiplicityRange poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:MultiplicityRange"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.lowerBound != null && poco.lowerBound.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "lowerBound", null, poco.lowerBound.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.upperBound != null && poco.upperBound.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "upperBound", null, poco.upperBound.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.bound != null) + { + foreach (var item in poco.bound) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "bound", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.lowerBound != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.lowerBound.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.lowerBound, "lowerBound", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.upperBound != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.upperBound.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.upperBound, "upperBound", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MultiplicityWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MultiplicityWriter.cs new file mode 100644 index 000000000..f70e9ec64 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/MultiplicityWriter.cs @@ -0,0 +1,1572 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class MultiplicityWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public MultiplicityWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IMultiplicity poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Multiplicity"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IMultiplicity poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Multiplicity"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/NamespaceExposeWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/NamespaceExposeWriter.cs new file mode 100644 index 000000000..2aeda3a1a --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/NamespaceExposeWriter.cs @@ -0,0 +1,553 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class NamespaceExposeWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public NamespaceExposeWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, INamespaceExpose poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:NamespaceExpose"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.importedElement != null && poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("importedElement", poco.importedElement.Id.ToString()); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ImportedNamespace != null && poco.ImportedNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("importedNamespace", poco.ImportedNamespace.Id.ToString()); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (!poco.IsImportAll) + { + xmlWriter.WriteAttributeString("isImportAll", "false"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsRecursive) + { + xmlWriter.WriteAttributeString("isRecursive", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Protected) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.importedElement, "importedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.ImportedNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ImportedNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.ImportedNamespace, "importedNamespace", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, INamespaceExpose poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:NamespaceExpose"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.importedElement != null && poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "importedElement", null, poco.importedElement.Id.ToString()); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ImportedNamespace != null && poco.ImportedNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "importedNamespace", null, poco.ImportedNamespace.Id.ToString()); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (!poco.IsImportAll) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImportAll", null, "false"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsRecursive) + { + await xmlWriter.WriteAttributeStringAsync(null, "isRecursive", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Protected) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.importedElement, "importedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.ImportedNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ImportedNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.ImportedNamespace, "importedNamespace", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/NamespaceImportWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/NamespaceImportWriter.cs new file mode 100644 index 000000000..975e7e5dc --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/NamespaceImportWriter.cs @@ -0,0 +1,552 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class NamespaceImportWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public NamespaceImportWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, INamespaceImport poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:NamespaceImport"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.importedElement != null && poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("importedElement", poco.importedElement.Id.ToString()); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ImportedNamespace != null && poco.ImportedNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("importedNamespace", poco.ImportedNamespace.Id.ToString()); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsImportAll) + { + xmlWriter.WriteAttributeString("isImportAll", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsRecursive) + { + xmlWriter.WriteAttributeString("isRecursive", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Private) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.importedElement, "importedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.ImportedNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ImportedNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.ImportedNamespace, "importedNamespace", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, INamespaceImport poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:NamespaceImport"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.importedElement != null && poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "importedElement", null, poco.importedElement.Id.ToString()); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ImportedNamespace != null && poco.ImportedNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "importedNamespace", null, poco.ImportedNamespace.Id.ToString()); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsImportAll) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImportAll", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsRecursive) + { + await xmlWriter.WriteAttributeStringAsync(null, "isRecursive", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Private) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.importedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.importedElement, "importedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.ImportedNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ImportedNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.ImportedNamespace, "importedNamespace", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/NamespaceWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/NamespaceWriter.cs new file mode 100644 index 000000000..3f2815418 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/NamespaceWriter.cs @@ -0,0 +1,541 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class NamespaceWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public NamespaceWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, INamespace poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Namespace"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, INamespace poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Namespace"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/NullExpressionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/NullExpressionWriter.cs new file mode 100644 index 000000000..2d044d9a3 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/NullExpressionWriter.cs @@ -0,0 +1,1667 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class NullExpressionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public NullExpressionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, INullExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:NullExpression"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, INullExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:NullExpression"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ObjectiveMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ObjectiveMembershipWriter.cs new file mode 100644 index 000000000..02c3a6b69 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ObjectiveMembershipWriter.cs @@ -0,0 +1,552 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ObjectiveMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ObjectiveMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IObjectiveMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ObjectiveMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedObjectiveRequirement != null && poco.ownedObjectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedObjectiveRequirement", poco.ownedObjectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedObjectiveRequirement != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedObjectiveRequirement, "ownedObjectiveRequirement", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IObjectiveMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ObjectiveMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedObjectiveRequirement != null && poco.ownedObjectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedObjectiveRequirement", null, poco.ownedObjectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedObjectiveRequirement != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedObjectiveRequirement, "ownedObjectiveRequirement", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/OccurrenceDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/OccurrenceDefinitionWriter.cs new file mode 100644 index 000000000..515e5c222 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/OccurrenceDefinitionWriter.cs @@ -0,0 +1,1815 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class OccurrenceDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public OccurrenceDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IOccurrenceDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:OccurrenceDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IOccurrenceDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:OccurrenceDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/OccurrenceUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/OccurrenceUsageWriter.cs new file mode 100644 index 000000000..f9c123957 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/OccurrenceUsageWriter.cs @@ -0,0 +1,2445 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class OccurrenceUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public OccurrenceUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IOccurrenceUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:OccurrenceUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IOccurrenceUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:OccurrenceUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/OperatorExpressionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/OperatorExpressionWriter.cs new file mode 100644 index 000000000..1ac25bc33 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/OperatorExpressionWriter.cs @@ -0,0 +1,1737 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class OperatorExpressionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public OperatorExpressionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IOperatorExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:OperatorExpression"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("instantiatedType", poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (!string.IsNullOrWhiteSpace(poco.Operator)) + { + xmlWriter.WriteAttributeString("operator", poco.Operator); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IOperatorExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:OperatorExpression"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "instantiatedType", null, poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (!string.IsNullOrWhiteSpace(poco.Operator)) + { + await xmlWriter.WriteAttributeStringAsync(null, "operator", null, poco.Operator); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/OwningMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/OwningMembershipWriter.cs new file mode 100644 index 000000000..7a20dbfa6 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/OwningMembershipWriter.cs @@ -0,0 +1,548 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class OwningMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public OwningMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IOwningMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:OwningMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedMemberElement != null && poco.ownedMemberElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedMemberElement", poco.ownedMemberElement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMemberElement != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedMemberElement, "ownedMemberElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IOwningMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:OwningMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedMemberElement != null && poco.ownedMemberElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElement", null, poco.ownedMemberElement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMemberElement != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedMemberElement, "ownedMemberElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PackageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PackageWriter.cs new file mode 100644 index 000000000..d70f74b85 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PackageWriter.cs @@ -0,0 +1,565 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Packages; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class PackageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public PackageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IPackage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Package"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.filterCondition != null) + { + foreach (var item in poco.filterCondition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "filterCondition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IPackage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Package"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.filterCondition != null) + { + foreach (var item in poco.filterCondition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "filterCondition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ParameterMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ParameterMembershipWriter.cs new file mode 100644 index 000000000..7e3893681 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ParameterMembershipWriter.cs @@ -0,0 +1,551 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ParameterMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ParameterMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IParameterMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ParameterMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedMemberParameter != null && poco.ownedMemberParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedMemberParameter", poco.ownedMemberParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMemberParameter != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedMemberParameter, "ownedMemberParameter", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IParameterMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ParameterMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedMemberParameter != null && poco.ownedMemberParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberParameter", null, poco.ownedMemberParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMemberParameter != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedMemberParameter, "ownedMemberParameter", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PartDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PartDefinitionWriter.cs new file mode 100644 index 000000000..5e9d728e8 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PartDefinitionWriter.cs @@ -0,0 +1,1814 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class PartDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public PartDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IPartDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:PartDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IPartDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:PartDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PartUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PartUsageWriter.cs new file mode 100644 index 000000000..2ced60b93 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PartUsageWriter.cs @@ -0,0 +1,2490 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Structures; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class PartUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public PartUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IPartUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:PartUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.partDefinition != null) + { + foreach (var item in poco.partDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "partDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IPartUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:PartUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.partDefinition != null) + { + foreach (var item in poco.partDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "partDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PayloadFeatureWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PayloadFeatureWriter.cs new file mode 100644 index 000000000..00513cd2e --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PayloadFeatureWriter.cs @@ -0,0 +1,1573 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Interactions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class PayloadFeatureWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public PayloadFeatureWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IPayloadFeature poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:PayloadFeature"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IPayloadFeature poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:PayloadFeature"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PerformActionUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PerformActionUsageWriter.cs new file mode 100644 index 000000000..147a8a721 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PerformActionUsageWriter.cs @@ -0,0 +1,2506 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class PerformActionUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public PerformActionUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IPerformActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:PerformActionUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "false"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.performedAction != null && poco.performedAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("performedAction", poco.performedAction.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.performedAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.performedAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.performedAction, "performedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IPerformActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:PerformActionUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "false"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.performedAction != null && poco.performedAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "performedAction", null, poco.performedAction.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.performedAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.performedAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.performedAction, "performedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PortConjugationWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PortConjugationWriter.cs new file mode 100644 index 000000000..bfdd500e3 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PortConjugationWriter.cs @@ -0,0 +1,549 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class PortConjugationWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public PortConjugationWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IPortConjugation poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:PortConjugation"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.conjugatedPortDefinition != null && poco.conjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("conjugatedPortDefinition", poco.conjugatedPortDefinition.Id.ToString()); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ConjugatedType != null && poco.ConjugatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("conjugatedType", poco.ConjugatedType.Id.ToString()); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.OriginalPortDefinition != null && poco.OriginalPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("originalPortDefinition", poco.OriginalPortDefinition.Id.ToString()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.conjugatedPortDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.conjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.conjugatedPortDefinition, "conjugatedPortDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (poco.ConjugatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ConjugatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.ConjugatedType, "conjugatedType", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OriginalPortDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.OriginalPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.OriginalPortDefinition, "originalPortDefinition", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IPortConjugation poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:PortConjugation"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.conjugatedPortDefinition != null && poco.conjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "conjugatedPortDefinition", null, poco.conjugatedPortDefinition.Id.ToString()); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ConjugatedType != null && poco.ConjugatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "conjugatedType", null, poco.ConjugatedType.Id.ToString()); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.OriginalPortDefinition != null && poco.OriginalPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "originalPortDefinition", null, poco.OriginalPortDefinition.Id.ToString()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.conjugatedPortDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.conjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.conjugatedPortDefinition, "conjugatedPortDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (poco.ConjugatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ConjugatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.ConjugatedType, "conjugatedType", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OriginalPortDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.OriginalPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.OriginalPortDefinition, "originalPortDefinition", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PortDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PortDefinitionWriter.cs new file mode 100644 index 000000000..197435752 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PortDefinitionWriter.cs @@ -0,0 +1,1853 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Structures; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class PortDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public PortDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IPortDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:PortDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.conjugatedPortDefinition != null && poco.conjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("conjugatedPortDefinition", poco.conjugatedPortDefinition.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.conjugatedPortDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.conjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.conjugatedPortDefinition, "conjugatedPortDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IPortDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:PortDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.conjugatedPortDefinition != null && poco.conjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "conjugatedPortDefinition", null, poco.conjugatedPortDefinition.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.conjugatedPortDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.conjugatedPortDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.conjugatedPortDefinition, "conjugatedPortDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PortUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PortUsageWriter.cs new file mode 100644 index 000000000..0cc7f0b7f --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PortUsageWriter.cs @@ -0,0 +1,2445 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class PortUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public PortUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IPortUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:PortUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.portDefinition != null) + { + foreach (var item in poco.portDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "portDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IPortUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:PortUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.portDefinition != null) + { + foreach (var item in poco.portDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "portDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PredicateWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PredicateWriter.cs new file mode 100644 index 000000000..d8df3a50b --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/PredicateWriter.cs @@ -0,0 +1,1190 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class PredicateWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public PredicateWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IPredicate poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Predicate"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IPredicate poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Predicate"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RedefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RedefinitionWriter.cs new file mode 100644 index 000000000..ba04f8c67 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RedefinitionWriter.cs @@ -0,0 +1,511 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class RedefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public RedefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IRedefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Redefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.RedefinedFeature != null && poco.RedefinedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("redefinedFeature", poco.RedefinedFeature.Id.ToString()); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.RedefiningFeature != null && poco.RedefiningFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("redefiningFeature", poco.RedefiningFeature.Id.ToString()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (poco.RedefinedFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.RedefinedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.RedefinedFeature, "redefinedFeature", elementOriginMap, currentFileUri); + } + } + + if (poco.RedefiningFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.RedefiningFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.RedefiningFeature, "redefiningFeature", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IRedefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Redefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.RedefinedFeature != null && poco.RedefinedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "redefinedFeature", null, poco.RedefinedFeature.Id.ToString()); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.RedefiningFeature != null && poco.RedefiningFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "redefiningFeature", null, poco.RedefiningFeature.Id.ToString()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (poco.RedefinedFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.RedefinedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.RedefinedFeature, "redefinedFeature", elementOriginMap, currentFileUri); + } + } + + if (poco.RedefiningFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.RedefiningFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.RedefiningFeature, "redefiningFeature", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ReferenceSubsettingWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ReferenceSubsettingWriter.cs new file mode 100644 index 000000000..c6ab8588d --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ReferenceSubsettingWriter.cs @@ -0,0 +1,485 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ReferenceSubsettingWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ReferenceSubsettingWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IReferenceSubsetting poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ReferenceSubsetting"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ReferencedFeature != null && poco.ReferencedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("referencedFeature", poco.ReferencedFeature.Id.ToString()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (poco.ReferencedFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ReferencedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.ReferencedFeature, "referencedFeature", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IReferenceSubsetting poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ReferenceSubsetting"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.ReferencedFeature != null && poco.ReferencedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "referencedFeature", null, poco.ReferencedFeature.Id.ToString()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (poco.ReferencedFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.ReferencedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.ReferencedFeature, "referencedFeature", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ReferenceUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ReferenceUsageWriter.cs new file mode 100644 index 000000000..9f8d4f271 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ReferenceUsageWriter.cs @@ -0,0 +1,2385 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ReferenceUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ReferenceUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IReferenceUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ReferenceUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "false"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.definition != null) + { + foreach (var item in poco.definition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "definition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IReferenceUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ReferenceUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "false"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.definition != null) + { + foreach (var item in poco.definition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "definition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RenderingDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RenderingDefinitionWriter.cs new file mode 100644 index 000000000..12b09f4c2 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RenderingDefinitionWriter.cs @@ -0,0 +1,1836 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class RenderingDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public RenderingDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IRenderingDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:RenderingDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.rendering != null) + { + foreach (var item in poco.rendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "rendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IRenderingDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:RenderingDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.rendering != null) + { + foreach (var item in poco.rendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "rendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RenderingUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RenderingUsageWriter.cs new file mode 100644 index 000000000..019385927 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RenderingUsageWriter.cs @@ -0,0 +1,2506 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Structures; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class RenderingUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public RenderingUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IRenderingUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:RenderingUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.renderingDefinition != null && poco.renderingDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("renderingDefinition", poco.renderingDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.renderingDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.renderingDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.renderingDefinition, "renderingDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IRenderingUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:RenderingUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.renderingDefinition != null && poco.renderingDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "renderingDefinition", null, poco.renderingDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.renderingDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.renderingDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.renderingDefinition, "renderingDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RequirementConstraintMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RequirementConstraintMembershipWriter.cs new file mode 100644 index 000000000..c6f32e351 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RequirementConstraintMembershipWriter.cs @@ -0,0 +1,595 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.Systems.Requirements; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class RequirementConstraintMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public RequirementConstraintMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IRequirementConstraintMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:RequirementConstraintMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + xmlWriter.WriteAttributeString("kind", poco.Kind.ToString().ToLower()); + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConstraint != null && poco.ownedConstraint.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConstraint", poco.ownedConstraint.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.referencedConstraint != null && poco.referencedConstraint.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("referencedConstraint", poco.referencedConstraint.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConstraint, "ownedConstraint", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.referencedConstraint != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.referencedConstraint.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.referencedConstraint, "referencedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IRequirementConstraintMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:RequirementConstraintMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + await xmlWriter.WriteAttributeStringAsync(null, "kind", null, poco.Kind.ToString().ToLower()); + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConstraint != null && poco.ownedConstraint.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConstraint", null, poco.ownedConstraint.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.referencedConstraint != null && poco.referencedConstraint.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "referencedConstraint", null, poco.referencedConstraint.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConstraint, "ownedConstraint", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.referencedConstraint != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.referencedConstraint.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.referencedConstraint, "referencedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RequirementDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RequirementDefinitionWriter.cs new file mode 100644 index 000000000..eca6b3838 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RequirementDefinitionWriter.cs @@ -0,0 +1,2078 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class RequirementDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public RequirementDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IRequirementDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:RequirementDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ReqId)) + { + xmlWriter.WriteAttributeString("reqId", poco.ReqId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.text != null && poco.text.Count > 0) + { + xmlWriter.WriteAttributeString("text", string.Join(" ", poco.text)); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assumedConstraint != null) + { + foreach (var item in poco.assumedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "assumedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.framedConcern != null) + { + foreach (var item in poco.framedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "framedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requiredConstraint != null) + { + foreach (var item in poco.requiredConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "requiredConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stakeholderParameter != null) + { + foreach (var item in poco.stakeholderParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "stakeholderParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IRequirementDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:RequirementDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ReqId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "reqId", null, poco.ReqId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.text != null && poco.text.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "text", null, string.Join(" ", poco.text)); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assumedConstraint != null) + { + foreach (var item in poco.assumedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "assumedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.framedConcern != null) + { + foreach (var item in poco.framedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "framedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requiredConstraint != null) + { + foreach (var item in poco.requiredConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "requiredConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stakeholderParameter != null) + { + foreach (var item in poco.stakeholderParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "stakeholderParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RequirementUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RequirementUsageWriter.cs new file mode 100644 index 000000000..8c7da058a --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RequirementUsageWriter.cs @@ -0,0 +1,2703 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class RequirementUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public RequirementUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IRequirementUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:RequirementUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ReqId)) + { + xmlWriter.WriteAttributeString("reqId", poco.ReqId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.requirementDefinition != null && poco.requirementDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("requirementDefinition", poco.requirementDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.text != null && poco.text.Count > 0) + { + xmlWriter.WriteAttributeString("text", string.Join(" ", poco.text)); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assumedConstraint != null) + { + foreach (var item in poco.assumedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "assumedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.framedConcern != null) + { + foreach (var item in poco.framedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "framedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requiredConstraint != null) + { + foreach (var item in poco.requiredConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "requiredConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requirementDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.requirementDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.requirementDefinition, "requirementDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stakeholderParameter != null) + { + foreach (var item in poco.stakeholderParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "stakeholderParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IRequirementUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:RequirementUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ReqId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "reqId", null, poco.ReqId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.requirementDefinition != null && poco.requirementDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "requirementDefinition", null, poco.requirementDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.text != null && poco.text.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "text", null, string.Join(" ", poco.text)); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assumedConstraint != null) + { + foreach (var item in poco.assumedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "assumedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.framedConcern != null) + { + foreach (var item in poco.framedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "framedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requiredConstraint != null) + { + foreach (var item in poco.requiredConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "requiredConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requirementDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.requirementDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.requirementDefinition, "requirementDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stakeholderParameter != null) + { + foreach (var item in poco.stakeholderParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "stakeholderParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RequirementVerificationMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RequirementVerificationMembershipWriter.cs new file mode 100644 index 000000000..39cd2602f --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/RequirementVerificationMembershipWriter.cs @@ -0,0 +1,602 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.Systems.Requirements; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class RequirementVerificationMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public RequirementVerificationMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IRequirementVerificationMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:RequirementVerificationMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.Kind != RequirementConstraintKind.Requirement) + { + xmlWriter.WriteAttributeString("kind", poco.Kind.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedRequirement != null && poco.ownedRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedRequirement", poco.ownedRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.verifiedRequirement != null && poco.verifiedRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("verifiedRequirement", poco.verifiedRequirement.Id.ToString()); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedRequirement, "ownedRequirement", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.verifiedRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.verifiedRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.verifiedRequirement, "verifiedRequirement", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IRequirementVerificationMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:RequirementVerificationMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.Kind != RequirementConstraintKind.Requirement) + { + await xmlWriter.WriteAttributeStringAsync(null, "kind", null, poco.Kind.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedRequirement != null && poco.ownedRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedRequirement", null, poco.ownedRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.verifiedRequirement != null && poco.verifiedRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "verifiedRequirement", null, poco.verifiedRequirement.Id.ToString()); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedRequirement, "ownedRequirement", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.verifiedRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.verifiedRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.verifiedRequirement, "verifiedRequirement", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ResultExpressionMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ResultExpressionMembershipWriter.cs new file mode 100644 index 000000000..c546d60f2 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ResultExpressionMembershipWriter.cs @@ -0,0 +1,551 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ResultExpressionMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ResultExpressionMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IResultExpressionMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ResultExpressionMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedResultExpression != null && poco.ownedResultExpression.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedResultExpression", poco.ownedResultExpression.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedResultExpression != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedResultExpression, "ownedResultExpression", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IResultExpressionMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ResultExpressionMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedResultExpression != null && poco.ownedResultExpression.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedResultExpression", null, poco.ownedResultExpression.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedResultExpression != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedResultExpression, "ownedResultExpression", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ReturnParameterMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ReturnParameterMembershipWriter.cs new file mode 100644 index 000000000..46dcff0a4 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ReturnParameterMembershipWriter.cs @@ -0,0 +1,552 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ReturnParameterMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ReturnParameterMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IReturnParameterMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ReturnParameterMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedMemberParameter != null && poco.ownedMemberParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedMemberParameter", poco.ownedMemberParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMemberParameter != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedMemberParameter, "ownedMemberParameter", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IReturnParameterMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ReturnParameterMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedMemberParameter != null && poco.ownedMemberParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberParameter", null, poco.ownedMemberParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMemberParameter != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedMemberParameter, "ownedMemberParameter", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SatisfyRequirementUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SatisfyRequirementUsageWriter.cs new file mode 100644 index 000000000..227ff5474 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SatisfyRequirementUsageWriter.cs @@ -0,0 +1,2789 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class SatisfyRequirementUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public SatisfyRequirementUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ISatisfyRequirementUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:SatisfyRequirementUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsNegated) + { + xmlWriter.WriteAttributeString("isNegated", "true"); + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ReqId)) + { + xmlWriter.WriteAttributeString("reqId", poco.ReqId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.requirementDefinition != null && poco.requirementDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("requirementDefinition", poco.requirementDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.satisfiedRequirement != null && poco.satisfiedRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("satisfiedRequirement", poco.satisfiedRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.satisfyingFeature != null && poco.satisfyingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("satisfyingFeature", poco.satisfyingFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.text != null && poco.text.Count > 0) + { + xmlWriter.WriteAttributeString("text", string.Join(" ", poco.text)); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assumedConstraint != null) + { + foreach (var item in poco.assumedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "assumedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.framedConcern != null) + { + foreach (var item in poco.framedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "framedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requiredConstraint != null) + { + foreach (var item in poco.requiredConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "requiredConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requirementDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.requirementDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.requirementDefinition, "requirementDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.satisfiedRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.satisfiedRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.satisfiedRequirement, "satisfiedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.satisfyingFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.satisfyingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.satisfyingFeature, "satisfyingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stakeholderParameter != null) + { + foreach (var item in poco.stakeholderParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "stakeholderParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ISatisfyRequirementUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:SatisfyRequirementUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsNegated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isNegated", null, "true"); + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ReqId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "reqId", null, poco.ReqId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.requirementDefinition != null && poco.requirementDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "requirementDefinition", null, poco.requirementDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.satisfiedRequirement != null && poco.satisfiedRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "satisfiedRequirement", null, poco.satisfiedRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.satisfyingFeature != null && poco.satisfyingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "satisfyingFeature", null, poco.satisfyingFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.text != null && poco.text.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "text", null, string.Join(" ", poco.text)); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assumedConstraint != null) + { + foreach (var item in poco.assumedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "assumedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.framedConcern != null) + { + foreach (var item in poco.framedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "framedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requiredConstraint != null) + { + foreach (var item in poco.requiredConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "requiredConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requirementDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.requirementDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.requirementDefinition, "requirementDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.satisfiedRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.satisfiedRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.satisfiedRequirement, "satisfiedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.satisfyingFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.satisfyingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.satisfyingFeature, "satisfyingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stakeholderParameter != null) + { + foreach (var item in poco.stakeholderParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "stakeholderParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SelectExpressionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SelectExpressionWriter.cs new file mode 100644 index 000000000..4040d059f --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SelectExpressionWriter.cs @@ -0,0 +1,1743 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class SelectExpressionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public SelectExpressionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ISelectExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:SelectExpression"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("instantiatedType", poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (poco.Operator != "select") + { + if (!string.IsNullOrWhiteSpace(poco.Operator)) + { + xmlWriter.WriteAttributeString("operator", poco.Operator); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ISelectExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:SelectExpression"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "instantiatedType", null, poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (poco.Operator != "select") + { + if (!string.IsNullOrWhiteSpace(poco.Operator)) + { + await xmlWriter.WriteAttributeStringAsync(null, "operator", null, poco.Operator); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SendActionUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SendActionUsageWriter.cs new file mode 100644 index 000000000..a559d810b --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SendActionUsageWriter.cs @@ -0,0 +1,2583 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class SendActionUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public SendActionUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ISendActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:SendActionUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.payloadArgument != null && poco.payloadArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("payloadArgument", poco.payloadArgument.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.receiverArgument != null && poco.receiverArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("receiverArgument", poco.receiverArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.senderArgument != null && poco.senderArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("senderArgument", poco.senderArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.payloadArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.payloadArgument, "payloadArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.receiverArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.receiverArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.receiverArgument, "receiverArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.senderArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.senderArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.senderArgument, "senderArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ISendActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:SendActionUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.payloadArgument != null && poco.payloadArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "payloadArgument", null, poco.payloadArgument.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.receiverArgument != null && poco.receiverArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "receiverArgument", null, poco.receiverArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.senderArgument != null && poco.senderArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "senderArgument", null, poco.senderArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.payloadArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.payloadArgument, "payloadArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.receiverArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.receiverArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.receiverArgument, "receiverArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.senderArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.senderArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.senderArgument, "senderArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SpecializationWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SpecializationWriter.cs new file mode 100644 index 000000000..77e8d151e --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SpecializationWriter.cs @@ -0,0 +1,510 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class SpecializationWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public SpecializationWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ISpecialization poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Specialization"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.General != null && poco.General.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("general", poco.General.Id.ToString()); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.Specific != null && poco.Specific.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("specific", poco.Specific.Id.ToString()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.General != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.General.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.General, "general", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.Specific != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.Specific.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.Specific, "specific", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ISpecialization poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Specialization"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.General != null && poco.General.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "general", null, poco.General.Id.ToString()); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.Specific != null && poco.Specific.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "specific", null, poco.Specific.Id.ToString()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.General != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.General.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.General, "general", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.Specific != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.Specific.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.Specific, "specific", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StakeholderMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StakeholderMembershipWriter.cs new file mode 100644 index 000000000..89928330f --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StakeholderMembershipWriter.cs @@ -0,0 +1,553 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class StakeholderMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public StakeholderMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IStakeholderMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:StakeholderMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedStakeholderParameter != null && poco.ownedStakeholderParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedStakeholderParameter", poco.ownedStakeholderParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedStakeholderParameter != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedStakeholderParameter, "ownedStakeholderParameter", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IStakeholderMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:StakeholderMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedStakeholderParameter != null && poco.ownedStakeholderParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedStakeholderParameter", null, poco.ownedStakeholderParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedStakeholderParameter != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedStakeholderParameter, "ownedStakeholderParameter", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StateDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StateDefinitionWriter.cs new file mode 100644 index 000000000..34bb3a83e --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StateDefinitionWriter.cs @@ -0,0 +1,2005 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class StateDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public StateDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IStateDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:StateDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.doAction != null && poco.doAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("doAction", poco.doAction.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.entryAction != null && poco.entryAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("entryAction", poco.entryAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.exitAction != null && poco.exitAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("exitAction", poco.exitAction.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsParallel) + { + xmlWriter.WriteAttributeString("isParallel", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.doAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.doAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.doAction, "doAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.entryAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.entryAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.entryAction, "entryAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.exitAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.exitAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.exitAction, "exitAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.state != null) + { + foreach (var item in poco.state) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "state", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IStateDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:StateDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.doAction != null && poco.doAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "doAction", null, poco.doAction.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.entryAction != null && poco.entryAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "entryAction", null, poco.entryAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.exitAction != null && poco.exitAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "exitAction", null, poco.exitAction.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsParallel) + { + await xmlWriter.WriteAttributeStringAsync(null, "isParallel", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.doAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.doAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.doAction, "doAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.entryAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.entryAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.entryAction, "entryAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.exitAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.exitAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.exitAction, "exitAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.state != null) + { + foreach (var item in poco.state) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "state", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StateSubactionMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StateSubactionMembershipWriter.cs new file mode 100644 index 000000000..c29d14092 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StateSubactionMembershipWriter.cs @@ -0,0 +1,557 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.Systems.States; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class StateSubactionMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public StateSubactionMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IStateSubactionMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:StateSubactionMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.action != null && poco.action.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("action", poco.action.Id.ToString()); + } + } + + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + xmlWriter.WriteAttributeString("kind", poco.Kind.ToString().ToLower()); + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.action, "action", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IStateSubactionMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:StateSubactionMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.action != null && poco.action.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "action", null, poco.action.Id.ToString()); + } + } + + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + await xmlWriter.WriteAttributeStringAsync(null, "kind", null, poco.Kind.ToString().ToLower()); + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.action, "action", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StateUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StateUsageWriter.cs new file mode 100644 index 000000000..b3ac380bc --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StateUsageWriter.cs @@ -0,0 +1,2592 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class StateUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public StateUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IStateUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:StateUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.doAction != null && poco.doAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("doAction", poco.doAction.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.entryAction != null && poco.entryAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("entryAction", poco.entryAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.exitAction != null && poco.exitAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("exitAction", poco.exitAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsParallel) + { + xmlWriter.WriteAttributeString("isParallel", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.doAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.doAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.doAction, "doAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.entryAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.entryAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.entryAction, "entryAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.exitAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.exitAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.exitAction, "exitAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stateDefinition != null) + { + foreach (var item in poco.stateDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "stateDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IStateUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:StateUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.doAction != null && poco.doAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "doAction", null, poco.doAction.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.entryAction != null && poco.entryAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "entryAction", null, poco.entryAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.exitAction != null && poco.exitAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "exitAction", null, poco.exitAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsParallel) + { + await xmlWriter.WriteAttributeStringAsync(null, "isParallel", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.doAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.doAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.doAction, "doAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.entryAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.entryAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.entryAction, "entryAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.exitAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.exitAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.exitAction, "exitAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stateDefinition != null) + { + foreach (var item in poco.stateDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "stateDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StepWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StepWriter.cs new file mode 100644 index 000000000..e74203e90 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StepWriter.cs @@ -0,0 +1,1595 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class StepWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public StepWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IStep poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Step"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.behavior != null) + { + foreach (var item in poco.behavior) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "behavior", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IStep poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Step"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.behavior != null) + { + foreach (var item in poco.behavior) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "behavior", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StructureWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StructureWriter.cs new file mode 100644 index 000000000..c36de1d80 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/StructureWriter.cs @@ -0,0 +1,1092 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Structures; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class StructureWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public StructureWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IStructure poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Structure"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IStructure poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Structure"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SubclassificationWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SubclassificationWriter.cs new file mode 100644 index 000000000..d67b4bdfe --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SubclassificationWriter.cs @@ -0,0 +1,511 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class SubclassificationWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public SubclassificationWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ISubclassification poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Subclassification"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.Subclassifier != null && poco.Subclassifier.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subclassifier", poco.Subclassifier.Id.ToString()); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.Superclassifier != null && poco.Superclassifier.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("superclassifier", poco.Superclassifier.Id.ToString()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.Subclassifier != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.Subclassifier.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.Subclassifier, "subclassifier", elementOriginMap, currentFileUri); + } + } + + if (poco.Superclassifier != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.Superclassifier.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.Superclassifier, "superclassifier", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ISubclassification poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Subclassification"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.Subclassifier != null && poco.Subclassifier.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subclassifier", null, poco.Subclassifier.Id.ToString()); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.Superclassifier != null && poco.Superclassifier.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "superclassifier", null, poco.Superclassifier.Id.ToString()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.Subclassifier != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.Subclassifier.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.Subclassifier, "subclassifier", elementOriginMap, currentFileUri); + } + } + + if (poco.Superclassifier != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.Superclassifier.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.Superclassifier, "superclassifier", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SubjectMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SubjectMembershipWriter.cs new file mode 100644 index 000000000..4a7a56e67 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SubjectMembershipWriter.cs @@ -0,0 +1,553 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class SubjectMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public SubjectMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ISubjectMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:SubjectMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedSubjectParameter != null && poco.ownedSubjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedSubjectParameter", poco.ownedSubjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubjectParameter != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedSubjectParameter, "ownedSubjectParameter", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ISubjectMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:SubjectMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedSubjectParameter != null && poco.ownedSubjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedSubjectParameter", null, poco.ownedSubjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubjectParameter != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedSubjectParameter, "ownedSubjectParameter", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SubsettingWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SubsettingWriter.cs new file mode 100644 index 000000000..ac745d266 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SubsettingWriter.cs @@ -0,0 +1,511 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class SubsettingWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public SubsettingWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ISubsetting poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Subsetting"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.SubsettedFeature != null && poco.SubsettedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subsettedFeature", poco.SubsettedFeature.Id.ToString()); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.SubsettingFeature != null && poco.SubsettingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subsettingFeature", poco.SubsettingFeature.Id.ToString()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.SubsettedFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.SubsettedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.SubsettedFeature, "subsettedFeature", elementOriginMap, currentFileUri); + } + } + + if (poco.SubsettingFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.SubsettingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.SubsettingFeature, "subsettingFeature", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ISubsetting poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Subsetting"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.SubsettedFeature != null && poco.SubsettedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subsettedFeature", null, poco.SubsettedFeature.Id.ToString()); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.SubsettingFeature != null && poco.SubsettingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subsettingFeature", null, poco.SubsettingFeature.Id.ToString()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.SubsettedFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.SubsettedFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.SubsettedFeature, "subsettedFeature", elementOriginMap, currentFileUri); + } + } + + if (poco.SubsettingFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.SubsettingFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.SubsettingFeature, "subsettingFeature", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SuccessionAsUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SuccessionAsUsageWriter.cs new file mode 100644 index 000000000..2221fa49c --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SuccessionAsUsageWriter.cs @@ -0,0 +1,2555 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class SuccessionAsUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public SuccessionAsUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ISuccessionAsUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:SuccessionAsUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("defaultFeaturingType", poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceFeature", poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.association != null) + { + foreach (var item in poco.association) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "association", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.definition != null) + { + foreach (var item in poco.definition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "definition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ISuccessionAsUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:SuccessionAsUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "defaultFeaturingType", null, poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceFeature", null, poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.association != null) + { + foreach (var item in poco.association) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "association", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.definition != null) + { + foreach (var item in poco.definition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "definition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SuccessionFlowUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SuccessionFlowUsageWriter.cs new file mode 100644 index 000000000..24247196b --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SuccessionFlowUsageWriter.cs @@ -0,0 +1,2797 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Kernel.Interactions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class SuccessionFlowUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public SuccessionFlowUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ISuccessionFlowUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:SuccessionFlowUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("defaultFeaturingType", poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.payloadFeature != null && poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("payloadFeature", poco.payloadFeature.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceFeature", poco.sourceFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceOutputFeature != null && poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceOutputFeature", poco.sourceOutputFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.targetInputFeature != null && poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("targetInputFeature", poco.targetInputFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.flowDefinition != null) + { + foreach (var item in poco.flowDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "flowDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.flowEnd != null) + { + foreach (var item in poco.flowEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "flowEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.payloadFeature, "payloadFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadType != null) + { + foreach (var item in poco.payloadType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "payloadType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceOutputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceOutputFeature, "sourceOutputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetInputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.targetInputFeature, "targetInputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ISuccessionFlowUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:SuccessionFlowUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "defaultFeaturingType", null, poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.payloadFeature != null && poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "payloadFeature", null, poco.payloadFeature.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceFeature", null, poco.sourceFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceOutputFeature != null && poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceOutputFeature", null, poco.sourceOutputFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.targetInputFeature != null && poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "targetInputFeature", null, poco.targetInputFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.flowDefinition != null) + { + foreach (var item in poco.flowDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "flowDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.flowEnd != null) + { + foreach (var item in poco.flowEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "flowEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.payloadFeature, "payloadFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadType != null) + { + foreach (var item in poco.payloadType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "payloadType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceOutputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceOutputFeature, "sourceOutputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetInputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.targetInputFeature, "targetInputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SuccessionFlowWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SuccessionFlowWriter.cs new file mode 100644 index 000000000..099d50d2c --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SuccessionFlowWriter.cs @@ -0,0 +1,1881 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Interactions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class SuccessionFlowWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public SuccessionFlowWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ISuccessionFlow poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:SuccessionFlow"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("defaultFeaturingType", poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.payloadFeature != null && poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("payloadFeature", poco.payloadFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceFeature", poco.sourceFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceOutputFeature != null && poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceOutputFeature", poco.sourceOutputFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.targetInputFeature != null && poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("targetInputFeature", poco.targetInputFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.flowEnd != null) + { + foreach (var item in poco.flowEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "flowEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.interaction != null) + { + foreach (var item in poco.interaction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "interaction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.payloadFeature, "payloadFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadType != null) + { + foreach (var item in poco.payloadType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "payloadType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceOutputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceOutputFeature, "sourceOutputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetInputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.targetInputFeature, "targetInputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ISuccessionFlow poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:SuccessionFlow"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "defaultFeaturingType", null, poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.payloadFeature != null && poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "payloadFeature", null, poco.payloadFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceFeature", null, poco.sourceFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceOutputFeature != null && poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceOutputFeature", null, poco.sourceOutputFeature.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.targetInputFeature != null && poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "targetInputFeature", null, poco.targetInputFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.flowEnd != null) + { + foreach (var item in poco.flowEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "flowEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.interaction != null) + { + foreach (var item in poco.interaction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "interaction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.payloadFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.payloadFeature, "payloadFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.payloadType != null) + { + foreach (var item in poco.payloadType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "payloadType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceOutputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceOutputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceOutputFeature, "sourceOutputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetInputFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.targetInputFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.targetInputFeature, "targetInputFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SuccessionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SuccessionWriter.cs new file mode 100644 index 000000000..b19a76a5a --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/SuccessionWriter.cs @@ -0,0 +1,1720 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Associations; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class SuccessionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public SuccessionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ISuccession poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Succession"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("defaultFeaturingType", poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("sourceFeature", poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.association != null) + { + foreach (var item in poco.association) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "association", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ISuccession poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Succession"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.defaultFeaturingType != null && poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "defaultFeaturingType", null, poco.defaultFeaturingType.Id.ToString()); + } + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.sourceFeature != null && poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "sourceFeature", null, poco.sourceFeature.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.association != null) + { + foreach (var item in poco.association) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "association", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.connectorEnd != null) + { + foreach (var item in poco.connectorEnd) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "connectorEnd", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.defaultFeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.defaultFeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.defaultFeaturingType, "defaultFeaturingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedFeature != null) + { + foreach (var item in poco.relatedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.sourceFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.sourceFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.sourceFeature, "sourceFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.targetFeature != null) + { + foreach (var item in poco.targetFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "targetFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TerminateActionUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TerminateActionUsageWriter.cs new file mode 100644 index 000000000..2ed2b07c0 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TerminateActionUsageWriter.cs @@ -0,0 +1,2507 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class TerminateActionUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public TerminateActionUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ITerminateActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:TerminateActionUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.terminatedOccurrenceArgument != null && poco.terminatedOccurrenceArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("terminatedOccurrenceArgument", poco.terminatedOccurrenceArgument.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.terminatedOccurrenceArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.terminatedOccurrenceArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.terminatedOccurrenceArgument, "terminatedOccurrenceArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ITerminateActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:TerminateActionUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.terminatedOccurrenceArgument != null && poco.terminatedOccurrenceArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "terminatedOccurrenceArgument", null, poco.terminatedOccurrenceArgument.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.terminatedOccurrenceArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.terminatedOccurrenceArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.terminatedOccurrenceArgument, "terminatedOccurrenceArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TextualRepresentationWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TextualRepresentationWriter.cs new file mode 100644 index 000000000..dac03ae37 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TextualRepresentationWriter.cs @@ -0,0 +1,511 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class TextualRepresentationWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public TextualRepresentationWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ITextualRepresentation poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:TextualRepresentation"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.Body)) + { + xmlWriter.WriteAttributeString("body", poco.Body); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (!string.IsNullOrWhiteSpace(poco.Language)) + { + xmlWriter.WriteAttributeString("language", poco.Language); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.representedElement != null && poco.representedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("representedElement", poco.representedElement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotation != null) + { + foreach (var item in poco.annotation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "annotation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotatingRelationship != null) + { + foreach (var item in poco.ownedAnnotatingRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotatingRelationship", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.representedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.representedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.representedElement, "representedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ITextualRepresentation poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:TextualRepresentation"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.Body)) + { + await xmlWriter.WriteAttributeStringAsync(null, "body", null, poco.Body); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (!string.IsNullOrWhiteSpace(poco.Language)) + { + await xmlWriter.WriteAttributeStringAsync(null, "language", null, poco.Language); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.representedElement != null && poco.representedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "representedElement", null, poco.representedElement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.annotation != null) + { + foreach (var item in poco.annotation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "annotation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotatingRelationship != null) + { + foreach (var item in poco.ownedAnnotatingRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotatingRelationship", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.representedElement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.representedElement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.representedElement, "representedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TransitionFeatureMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TransitionFeatureMembershipWriter.cs new file mode 100644 index 000000000..8b65f658e --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TransitionFeatureMembershipWriter.cs @@ -0,0 +1,557 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.Systems.States; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class TransitionFeatureMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public TransitionFeatureMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ITransitionFeatureMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:TransitionFeatureMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + xmlWriter.WriteAttributeString("kind", poco.Kind.ToString().ToLower()); + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.transitionFeature != null && poco.transitionFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("transitionFeature", poco.transitionFeature.Id.ToString()); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.transitionFeature != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.transitionFeature, "transitionFeature", writerOptions, elementOriginMap, currentFileUri); + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ITransitionFeatureMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:TransitionFeatureMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + await xmlWriter.WriteAttributeStringAsync(null, "kind", null, poco.Kind.ToString().ToLower()); + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.transitionFeature != null && poco.transitionFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "transitionFeature", null, poco.transitionFeature.Id.ToString()); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.transitionFeature != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.transitionFeature, "transitionFeature", writerOptions, elementOriginMap, currentFileUri); + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TransitionUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TransitionUsageWriter.cs new file mode 100644 index 000000000..54929bc44 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TransitionUsageWriter.cs @@ -0,0 +1,2650 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Connectors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class TransitionUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public TransitionUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ITransitionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:TransitionUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.source != null && poco.source.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("source", poco.source.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.succession != null && poco.succession.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("succession", poco.succession.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.target != null && poco.target.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("target", poco.target.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.effectAction != null) + { + foreach (var item in poco.effectAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "effectAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.guardExpression != null) + { + foreach (var item in poco.guardExpression) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "guardExpression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.source != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.source.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.source, "source", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.succession != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.succession.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.succession, "succession", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.target != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.target.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.target, "target", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.triggerAction != null) + { + foreach (var item in poco.triggerAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "triggerAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ITransitionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:TransitionUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.source != null && poco.source.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "source", null, poco.source.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.succession != null && poco.succession.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "succession", null, poco.succession.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.target != null && poco.target.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "target", null, poco.target.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.effectAction != null) + { + foreach (var item in poco.effectAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "effectAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.guardExpression != null) + { + foreach (var item in poco.guardExpression) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "guardExpression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.source != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.source.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.source, "source", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.succession != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.succession.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.succession, "succession", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.target != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.target.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.target, "target", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.triggerAction != null) + { + foreach (var item in poco.triggerAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "triggerAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TriggerInvocationExpressionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TriggerInvocationExpressionWriter.cs new file mode 100644 index 000000000..3e93e8328 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TriggerInvocationExpressionWriter.cs @@ -0,0 +1,1733 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Actions; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Expressions; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class TriggerInvocationExpressionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public TriggerInvocationExpressionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ITriggerInvocationExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:TriggerInvocationExpression"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("function", poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("instantiatedType", poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariable) + { + xmlWriter.WriteAttributeString("isVariable", "true"); + } + + xmlWriter.WriteAttributeString("kind", poco.Kind.ToString().ToLower()); + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ITriggerInvocationExpression poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:TriggerInvocationExpression"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.function != null && poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "function", null, poco.function.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.instantiatedType != null && poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "instantiatedType", null, poco.instantiatedType.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariable", null, "true"); + } + + await xmlWriter.WriteAttributeStringAsync(null, "kind", null, poco.Kind.ToString().ToLower()); + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.argument != null) + { + foreach (var item in poco.argument) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "argument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.function != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.function.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.function, "function", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.instantiatedType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.instantiatedType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.instantiatedType, "instantiatedType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.type != null) + { + foreach (var item in poco.type) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "type", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TypeFeaturingWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TypeFeaturingWriter.cs new file mode 100644 index 000000000..ae34dd44e --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TypeFeaturingWriter.cs @@ -0,0 +1,511 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class TypeFeaturingWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public TypeFeaturingWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, ITypeFeaturing poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:TypeFeaturing"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.FeatureOfType != null && poco.FeatureOfType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureOfType", poco.FeatureOfType.Id.ToString()); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.FeaturingType != null && poco.FeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featuringType", poco.FeaturingType.Id.ToString()); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.FeatureOfType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.FeatureOfType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.FeatureOfType, "featureOfType", elementOriginMap, currentFileUri); + } + } + + if (poco.FeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.FeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.FeaturingType, "featuringType", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, ITypeFeaturing poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:TypeFeaturing"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.FeatureOfType != null && poco.FeatureOfType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureOfType", null, poco.FeatureOfType.Id.ToString()); + } + + if (writerOptions.WriteIdRefAsAttribute && poco.FeaturingType != null && poco.FeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featuringType", null, poco.FeaturingType.Id.ToString()); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.FeatureOfType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.FeatureOfType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.FeatureOfType, "featureOfType", elementOriginMap, currentFileUri); + } + } + + if (poco.FeaturingType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.FeaturingType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.FeaturingType, "featuringType", elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TypeWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TypeWriter.cs new file mode 100644 index 000000000..bb876299b --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/TypeWriter.cs @@ -0,0 +1,1067 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class TypeWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public TypeWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IType poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Type"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IType poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Type"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/UnioningWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/UnioningWriter.cs new file mode 100644 index 000000000..0ca98d31c --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/UnioningWriter.cs @@ -0,0 +1,484 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class UnioningWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public UnioningWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IUnioning poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Unioning"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.UnioningType != null && poco.UnioningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("unioningType", poco.UnioningType.Id.ToString()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.UnioningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.UnioningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.UnioningType, "unioningType", elementOriginMap, currentFileUri); + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IUnioning poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Unioning"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.WriteIdRefAsAttribute && poco.UnioningType != null && poco.UnioningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "unioningType", null, poco.UnioningType.Id.ToString()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (poco.UnioningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.UnioningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.UnioningType, "unioningType", elementOriginMap, currentFileUri); + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/UsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/UsageWriter.cs new file mode 100644 index 000000000..17a62b8b6 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/UsageWriter.cs @@ -0,0 +1,2385 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class UsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public UsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:Usage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.definition != null) + { + foreach (var item in poco.definition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "definition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:Usage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.definition != null) + { + foreach (var item in poco.definition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "definition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/UseCaseDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/UseCaseDefinitionWriter.cs new file mode 100644 index 000000000..0f597762a --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/UseCaseDefinitionWriter.cs @@ -0,0 +1,2078 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class UseCaseDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public UseCaseDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IUseCaseDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:UseCaseDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("objectiveRequirement", poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.calculation != null) + { + foreach (var item in poco.calculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "calculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.includedUseCase != null) + { + foreach (var item in poco.includedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "includedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IUseCaseDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:UseCaseDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "objectiveRequirement", null, poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.calculation != null) + { + foreach (var item in poco.calculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "calculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.includedUseCase != null) + { + foreach (var item in poco.includedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "includedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/UseCaseUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/UseCaseUsageWriter.cs new file mode 100644 index 000000000..12267c7a2 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/UseCaseUsageWriter.cs @@ -0,0 +1,2681 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class UseCaseUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public UseCaseUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IUseCaseUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:UseCaseUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("objectiveRequirement", poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.useCaseDefinition != null && poco.useCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("useCaseDefinition", poco.useCaseDefinition.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.includedUseCase != null) + { + foreach (var item in poco.includedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "includedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.useCaseDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.useCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.useCaseDefinition, "useCaseDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IUseCaseUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:UseCaseUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "objectiveRequirement", null, poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.useCaseDefinition != null && poco.useCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "useCaseDefinition", null, poco.useCaseDefinition.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.includedUseCase != null) + { + foreach (var item in poco.includedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "includedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.useCaseDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.useCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.useCaseDefinition, "useCaseDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/VariantMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/VariantMembershipWriter.cs new file mode 100644 index 000000000..c865c76d0 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/VariantMembershipWriter.cs @@ -0,0 +1,549 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class VariantMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public VariantMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IVariantMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:VariantMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedVariantUsage != null && poco.ownedVariantUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedVariantUsage", poco.ownedVariantUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVariantUsage != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedVariantUsage, "ownedVariantUsage", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IVariantMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:VariantMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedVariantUsage != null && poco.ownedVariantUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedVariantUsage", null, poco.ownedVariantUsage.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVariantUsage != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedVariantUsage, "ownedVariantUsage", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/VerificationCaseDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/VerificationCaseDefinitionWriter.cs new file mode 100644 index 000000000..f85e0d0e1 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/VerificationCaseDefinitionWriter.cs @@ -0,0 +1,2078 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class VerificationCaseDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public VerificationCaseDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IVerificationCaseDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:VerificationCaseDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("objectiveRequirement", poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.calculation != null) + { + foreach (var item in poco.calculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "calculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.verifiedRequirement != null) + { + foreach (var item in poco.verifiedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "verifiedRequirement", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IVerificationCaseDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:VerificationCaseDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "objectiveRequirement", null, poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.action != null) + { + foreach (var item in poco.action) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "action", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.calculation != null) + { + foreach (var item in poco.calculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "calculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.verifiedRequirement != null) + { + foreach (var item in poco.verifiedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "verifiedRequirement", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/VerificationCaseUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/VerificationCaseUsageWriter.cs new file mode 100644 index 000000000..0168cddac --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/VerificationCaseUsageWriter.cs @@ -0,0 +1,2719 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class VerificationCaseUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public VerificationCaseUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IVerificationCaseUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:VerificationCaseUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.caseDefinition != null && poco.caseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("caseDefinition", poco.caseDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("objectiveRequirement", poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.verificationCaseDefinition != null && poco.verificationCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("verificationCaseDefinition", poco.verificationCaseDefinition.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.caseDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.caseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.caseDefinition, "caseDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.verificationCaseDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.verificationCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.verificationCaseDefinition, "verificationCaseDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.verifiedRequirement != null) + { + foreach (var item in poco.verifiedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "verifiedRequirement", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IVerificationCaseUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:VerificationCaseUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.caseDefinition != null && poco.caseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "caseDefinition", null, poco.caseDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.objectiveRequirement != null && poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "objectiveRequirement", null, poco.objectiveRequirement.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.verificationCaseDefinition != null && poco.verificationCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "verificationCaseDefinition", null, poco.verificationCaseDefinition.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.caseDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.caseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.caseDefinition, "caseDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.objectiveRequirement != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.objectiveRequirement.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.objectiveRequirement, "objectiveRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.verificationCaseDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.verificationCaseDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.verificationCaseDefinition, "verificationCaseDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.verifiedRequirement != null) + { + foreach (var item in poco.verifiedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "verifiedRequirement", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ViewDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ViewDefinitionWriter.cs new file mode 100644 index 000000000..5b1dac9fa --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ViewDefinitionWriter.cs @@ -0,0 +1,1919 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ViewDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ViewDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IViewDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ViewDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.viewRendering != null && poco.viewRendering.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("viewRendering", poco.viewRendering.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.satisfiedViewpoint != null) + { + foreach (var item in poco.satisfiedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "satisfiedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.view != null) + { + foreach (var item in poco.view) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "view", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewCondition != null) + { + foreach (var item in poco.viewCondition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "viewCondition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewRendering != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.viewRendering.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.viewRendering, "viewRendering", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IViewDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ViewDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.viewRendering != null && poco.viewRendering.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "viewRendering", null, poco.viewRendering.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.satisfiedViewpoint != null) + { + foreach (var item in poco.satisfiedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "satisfiedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.view != null) + { + foreach (var item in poco.view) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "view", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewCondition != null) + { + foreach (var item in poco.viewCondition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "viewCondition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewRendering != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.viewRendering.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.viewRendering, "viewRendering", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ViewRenderingMembershipWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ViewRenderingMembershipWriter.cs new file mode 100644 index 000000000..4004f99a2 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ViewRenderingMembershipWriter.cs @@ -0,0 +1,589 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Root.Namespaces; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ViewRenderingMembershipWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ViewRenderingMembershipWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IViewRenderingMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ViewRenderingMembership"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsImplied) + { + xmlWriter.WriteAttributeString("isImplied", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + xmlWriter.WriteAttributeString("ownedMemberElementId", poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + xmlWriter.WriteAttributeString("ownedMemberName", poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + xmlWriter.WriteAttributeString("ownedMemberShortName", poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedRendering != null && poco.ownedRendering.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedRendering", poco.ownedRendering.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.referencedRendering != null && poco.referencedRendering.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("referencedRendering", poco.referencedRendering.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + xmlWriter.WriteAttributeString("visibility", poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedRendering, "ownedRendering", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.referencedRendering != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.referencedRendering.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.referencedRendering, "referencedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IViewRenderingMembership poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ViewRenderingMembership"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsImplied) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImplied", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberElementId", null, poco.ownedMemberElementId); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberName", null, poco.ownedMemberName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.ownedMemberShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedMemberShortName", null, poco.ownedMemberShortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedRendering != null && poco.ownedRendering.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedRendering", null, poco.ownedRendering.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.referencedRendering != null && poco.referencedRendering.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "referencedRendering", null, poco.referencedRendering.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (poco.Visibility != VisibilityKind.Public) + { + await xmlWriter.WriteAttributeStringAsync(null, "visibility", null, poco.Visibility.ToString().ToLower()); + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (poco.OwnedRelatedElement != null) + { + foreach (var item in poco.OwnedRelatedElement) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelatedElement", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedRendering, "ownedRendering", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.referencedRendering != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.referencedRendering.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.referencedRendering, "referencedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.relatedElement != null) + { + foreach (var item in poco.relatedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "relatedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ViewUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ViewUsageWriter.cs new file mode 100644 index 000000000..041988add --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ViewUsageWriter.cs @@ -0,0 +1,2611 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Kernel.Structures; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ViewUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ViewUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IViewUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ViewUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.viewDefinition != null && poco.viewDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("viewDefinition", poco.viewDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.viewRendering != null && poco.viewRendering.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("viewRendering", poco.viewRendering.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.exposedElement != null) + { + foreach (var item in poco.exposedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "exposedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.satisfiedViewpoint != null) + { + foreach (var item in poco.satisfiedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "satisfiedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewCondition != null) + { + foreach (var item in poco.viewCondition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "viewCondition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.viewDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.viewDefinition, "viewDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewRendering != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.viewRendering.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.viewRendering, "viewRendering", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IViewUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ViewUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.viewDefinition != null && poco.viewDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "viewDefinition", null, poco.viewDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.viewRendering != null && poco.viewRendering.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "viewRendering", null, poco.viewRendering.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedFeature != null) + { + foreach (var item in poco.directedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.exposedElement != null) + { + foreach (var item in poco.exposedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "exposedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.itemDefinition != null) + { + foreach (var item in poco.itemDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "itemDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.satisfiedViewpoint != null) + { + foreach (var item in poco.satisfiedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "satisfiedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewCondition != null) + { + foreach (var item in poco.viewCondition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "viewCondition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.viewDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.viewDefinition, "viewDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewRendering != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.viewRendering.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.viewRendering, "viewRendering", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ViewpointDefinitionWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ViewpointDefinitionWriter.cs new file mode 100644 index 000000000..9e6c68ae9 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ViewpointDefinitionWriter.cs @@ -0,0 +1,2100 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ViewpointDefinitionWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ViewpointDefinitionWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IViewpointDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ViewpointDefinition"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ReqId)) + { + xmlWriter.WriteAttributeString("reqId", poco.ReqId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.text != null && poco.text.Count > 0) + { + xmlWriter.WriteAttributeString("text", string.Join(" ", poco.text)); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assumedConstraint != null) + { + foreach (var item in poco.assumedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "assumedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.framedConcern != null) + { + foreach (var item in poco.framedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "framedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requiredConstraint != null) + { + foreach (var item in poco.requiredConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "requiredConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stakeholderParameter != null) + { + foreach (var item in poco.stakeholderParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "stakeholderParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewpointStakeholder != null) + { + foreach (var item in poco.viewpointStakeholder) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "viewpointStakeholder", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IViewpointDefinition poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ViewpointDefinition"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ReqId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "reqId", null, poco.ReqId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.text != null && poco.text.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "text", null, string.Join(" ", poco.text)); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assumedConstraint != null) + { + foreach (var item in poco.assumedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "assumedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.expression != null) + { + foreach (var item in poco.expression) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "expression", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.framedConcern != null) + { + foreach (var item in poco.framedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "framedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAction != null) + { + foreach (var item in poco.ownedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAllocation != null) + { + foreach (var item in poco.ownedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnalysisCase != null) + { + foreach (var item in poco.ownedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAttribute != null) + { + foreach (var item in poco.ownedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCalculation != null) + { + foreach (var item in poco.ownedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCase != null) + { + foreach (var item in poco.ownedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConcern != null) + { + foreach (var item in poco.ownedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConnection != null) + { + foreach (var item in poco.ownedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConstraint != null) + { + foreach (var item in poco.ownedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEnumeration != null) + { + foreach (var item in poco.ownedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFlow != null) + { + foreach (var item in poco.ownedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedInterface != null) + { + foreach (var item in poco.ownedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedItem != null) + { + foreach (var item in poco.ownedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMetadata != null) + { + foreach (var item in poco.ownedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedOccurrence != null) + { + foreach (var item in poco.ownedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPart != null) + { + foreach (var item in poco.ownedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedPort != null) + { + foreach (var item in poco.ownedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReference != null) + { + foreach (var item in poco.ownedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedReference", elementOriginMap, currentFileUri); + } + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRendering != null) + { + foreach (var item in poco.ownedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRequirement != null) + { + foreach (var item in poco.ownedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedState != null) + { + foreach (var item in poco.ownedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubclassification != null) + { + foreach (var item in poco.ownedSubclassification) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubclassification", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTransition != null) + { + foreach (var item in poco.ownedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUsage != null) + { + foreach (var item in poco.ownedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUseCase != null) + { + foreach (var item in poco.ownedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedVerificationCase != null) + { + foreach (var item in poco.ownedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedView != null) + { + foreach (var item in poco.ownedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedViewpoint != null) + { + foreach (var item in poco.ownedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requiredConstraint != null) + { + foreach (var item in poco.requiredConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "requiredConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stakeholderParameter != null) + { + foreach (var item in poco.stakeholderParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "stakeholderParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.step != null) + { + foreach (var item in poco.step) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "step", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewpointStakeholder != null) + { + foreach (var item in poco.viewpointStakeholder) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "viewpointStakeholder", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ViewpointUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ViewpointUsageWriter.cs new file mode 100644 index 000000000..687d6b159 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/ViewpointUsageWriter.cs @@ -0,0 +1,2725 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class ViewpointUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public ViewpointUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IViewpointUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:ViewpointUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + xmlWriter.WriteAttributeString("isModelLevelEvaluable", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ReqId)) + { + xmlWriter.WriteAttributeString("reqId", poco.ReqId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("result", poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("subjectParameter", poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.text != null && poco.text.Count > 0) + { + xmlWriter.WriteAttributeString("text", string.Join(" ", poco.text)); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.viewpointDefinition != null && poco.viewpointDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("viewpointDefinition", poco.viewpointDefinition.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assumedConstraint != null) + { + foreach (var item in poco.assumedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "assumedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.framedConcern != null) + { + foreach (var item in poco.framedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "framedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requiredConstraint != null) + { + foreach (var item in poco.requiredConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "requiredConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stakeholderParameter != null) + { + foreach (var item in poco.stakeholderParameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "stakeholderParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewpointDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.viewpointDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.viewpointDefinition, "viewpointDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewpointStakeholder != null) + { + foreach (var item in poco.viewpointStakeholder) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "viewpointStakeholder", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IViewpointUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:ViewpointUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isModelLevelEvaluable) + { + await xmlWriter.WriteAttributeStringAsync(null, "isModelLevelEvaluable", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (!string.IsNullOrWhiteSpace(poco.ReqId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "reqId", null, poco.ReqId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.result != null && poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "result", null, poco.result.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.subjectParameter != null && poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "subjectParameter", null, poco.subjectParameter.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.text != null && poco.text.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "text", null, string.Join(" ", poco.text)); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.viewpointDefinition != null && poco.viewpointDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "viewpointDefinition", null, poco.viewpointDefinition.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actorParameter != null) + { + foreach (var item in poco.actorParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actorParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.assumedConstraint != null) + { + foreach (var item in poco.assumedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "assumedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.framedConcern != null) + { + foreach (var item in poco.framedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "framedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.requiredConstraint != null) + { + foreach (var item in poco.requiredConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "requiredConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.result != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.result.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.result, "result", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.stakeholderParameter != null) + { + foreach (var item in poco.stakeholderParameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "stakeholderParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.subjectParameter != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.subjectParameter.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.subjectParameter, "subjectParameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewpointDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.viewpointDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.viewpointDefinition, "viewpointDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.viewpointStakeholder != null) + { + foreach (var item in poco.viewpointStakeholder) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "viewpointStakeholder", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/WhileLoopActionUsageWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/WhileLoopActionUsageWriter.cs new file mode 100644 index 000000000..fb9cbe184 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/WhileLoopActionUsageWriter.cs @@ -0,0 +1,2583 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + using Microsoft.Extensions.Logging.Abstractions; + + using SysML2.NET.Common; + using SysML2.NET.Core.Core.Types; + using SysML2.NET.Core.Systems.Occurrences; + using SysML2.NET.Core.POCO.Core.Classifiers; + using SysML2.NET.Core.POCO.Core.Features; + using SysML2.NET.Core.POCO.Core.Types; + using SysML2.NET.Core.POCO.Kernel.Behaviors; + using SysML2.NET.Core.POCO.Kernel.Classes; + using SysML2.NET.Core.POCO.Kernel.Functions; + using SysML2.NET.Core.POCO.Root.Annotations; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Core.POCO.Root.Namespaces; + using SysML2.NET.Core.POCO.Systems.Allocations; + using SysML2.NET.Core.POCO.Systems.AnalysisCases; + using SysML2.NET.Core.POCO.Systems.Attributes; + using SysML2.NET.Core.POCO.Systems.Calculations; + using SysML2.NET.Core.POCO.Systems.Cases; + using SysML2.NET.Core.POCO.Systems.Connections; + using SysML2.NET.Core.POCO.Systems.Constraints; + using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage; + using SysML2.NET.Core.POCO.Systems.Enumerations; + using SysML2.NET.Core.POCO.Systems.Flows; + using SysML2.NET.Core.POCO.Systems.Interfaces; + using SysML2.NET.Core.POCO.Systems.Items; + using SysML2.NET.Core.POCO.Systems.Metadata; + using SysML2.NET.Core.POCO.Systems.Occurrences; + using SysML2.NET.Core.POCO.Systems.Parts; + using SysML2.NET.Core.POCO.Systems.Ports; + using SysML2.NET.Core.POCO.Systems.Requirements; + using SysML2.NET.Core.POCO.Systems.States; + using SysML2.NET.Core.POCO.Systems.UseCases; + using SysML2.NET.Core.POCO.Systems.VerificationCases; + using SysML2.NET.Core.POCO.Systems.Views; + using SysML2.NET.Core.POCO.Systems.Actions; + using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Serializer.Xmi.Extensions; + + /// + /// The purpose of the is to write an instance of + /// to the XMI document + /// + public class WhileLoopActionUsageWriter : XmiDataWriter + { + /// + /// The instantiated logger from the injected + /// + private readonly ILogger logger; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + public WhileLoopActionUsageWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) : base(xmiDataWriterFacade, loggerFactory) + { + this.logger = loggerFactory == null ? NullLogger.Instance : loggerFactory.CreateLogger(); + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public override void Write(XmlWriter xmlWriter, IWhileLoopActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xsi", "type", null, "sysml:WhileLoopActionUsage"); + xmlWriter.WriteAttributeString("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + xmlWriter.WriteAttributeString("aliasIds", string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.bodyAction != null && poco.bodyAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("bodyAction", poco.bodyAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("crossFeature", poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + xmlWriter.WriteAttributeString("declaredName", poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + xmlWriter.WriteAttributeString("declaredShortName", poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + xmlWriter.WriteAttributeString("direction", poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + xmlWriter.WriteAttributeString("elementId", poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("endOwningType", poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("featureTarget", poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("individualDefinition", poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + xmlWriter.WriteAttributeString("isAbstract", "true"); + } + + if (poco.IsComposite) + { + xmlWriter.WriteAttributeString("isComposite", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + xmlWriter.WriteAttributeString("isConjugated", "true"); + } + } + + if (poco.IsConstant) + { + xmlWriter.WriteAttributeString("isConstant", "true"); + } + + if (poco.IsDerived) + { + xmlWriter.WriteAttributeString("isDerived", "true"); + } + + if (poco.IsEnd) + { + xmlWriter.WriteAttributeString("isEnd", "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + xmlWriter.WriteAttributeString("isImpliedIncluded", "true"); + } + + if (poco.IsIndividual) + { + xmlWriter.WriteAttributeString("isIndividual", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + xmlWriter.WriteAttributeString("isLibraryElement", "true"); + } + } + + if (poco.IsOrdered) + { + xmlWriter.WriteAttributeString("isOrdered", "true"); + } + + if (poco.IsPortion) + { + xmlWriter.WriteAttributeString("isPortion", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + xmlWriter.WriteAttributeString("isReference", "true"); + } + } + + if (poco.IsSufficient) + { + xmlWriter.WriteAttributeString("isSufficient", "true"); + } + + if (!poco.IsUnique) + { + xmlWriter.WriteAttributeString("isUnique", "false"); + } + + if (poco.IsVariation) + { + xmlWriter.WriteAttributeString("isVariation", "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + xmlWriter.WriteAttributeString("mayTimeVary", "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("multiplicity", poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + xmlWriter.WriteAttributeString("name", poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedConjugator", poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedCrossSubsetting", poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("ownedReferenceSubsetting", poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owner", poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningDefinition", poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningNamespace", poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningType", poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("owningUsage", poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + xmlWriter.WriteAttributeString("portionKind", poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + xmlWriter.WriteAttributeString("qualifiedName", poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + xmlWriter.WriteAttributeString("shortName", poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.untilArgument != null && poco.untilArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("untilArgument", poco.untilArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.whileArgument != null && poco.whileArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + xmlWriter.WriteAttributeString("whileArgument", poco.whileArgument.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.bodyAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.bodyAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.bodyAction, "bodyAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.untilArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.untilArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.untilArgument, "untilArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + this.XmiDataWriterFacade.WriteContainedElement(xmlWriter, (IData)item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.whileArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.whileArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + this.XmiDataWriterFacade.WriteReferenceElement(xmlWriter, (IData)poco.whileArgument, "whileArgument", elementOriginMap, currentFileUri); + } + } + } + + + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public override async Task WriteAsync(XmlWriter xmlWriter, IWhileLoopActionUsage poco, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, "sysml:WhileLoopActionUsage"); + await xmlWriter.WriteAttributeStringAsync("xmi", "id", null, poco.Id.ToString()); + + // Scalar properties as XML attributes (sorted alphabetically) + if (poco.AliasIds != null && poco.AliasIds.Count > 0) + { + await xmlWriter.WriteAttributeStringAsync(null, "aliasIds", null, string.Join(" ", poco.AliasIds)); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.bodyAction != null && poco.bodyAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "bodyAction", null, poco.bodyAction.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.crossFeature != null && poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "crossFeature", null, poco.crossFeature.Id.ToString()); + } + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredName", null, poco.DeclaredName); + } + + if (!string.IsNullOrWhiteSpace(poco.DeclaredShortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "declaredShortName", null, poco.DeclaredShortName); + } + + if (poco.Direction.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "direction", null, poco.Direction.Value.ToString().ToLower()); + } + + if (!string.IsNullOrWhiteSpace(poco.ElementId)) + { + await xmlWriter.WriteAttributeStringAsync(null, "elementId", null, poco.ElementId); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.endOwningType != null && poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "endOwningType", null, poco.endOwningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.featureTarget != null && poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "featureTarget", null, poco.featureTarget.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.individualDefinition != null && poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "individualDefinition", null, poco.individualDefinition.Id.ToString()); + } + } + + if (poco.IsAbstract) + { + await xmlWriter.WriteAttributeStringAsync(null, "isAbstract", null, "true"); + } + + if (poco.IsComposite) + { + await xmlWriter.WriteAttributeStringAsync(null, "isComposite", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isConjugated) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConjugated", null, "true"); + } + } + + if (poco.IsConstant) + { + await xmlWriter.WriteAttributeStringAsync(null, "isConstant", null, "true"); + } + + if (poco.IsDerived) + { + await xmlWriter.WriteAttributeStringAsync(null, "isDerived", null, "true"); + } + + if (poco.IsEnd) + { + await xmlWriter.WriteAttributeStringAsync(null, "isEnd", null, "true"); + } + + if (writerOptions.IncludeImplied || poco.IsImpliedIncluded) + { + await xmlWriter.WriteAttributeStringAsync(null, "isImpliedIncluded", null, "true"); + } + + if (poco.IsIndividual) + { + await xmlWriter.WriteAttributeStringAsync(null, "isIndividual", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isLibraryElement) + { + await xmlWriter.WriteAttributeStringAsync(null, "isLibraryElement", null, "true"); + } + } + + if (poco.IsOrdered) + { + await xmlWriter.WriteAttributeStringAsync(null, "isOrdered", null, "true"); + } + + if (poco.IsPortion) + { + await xmlWriter.WriteAttributeStringAsync(null, "isPortion", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.isReference) + { + await xmlWriter.WriteAttributeStringAsync(null, "isReference", null, "true"); + } + } + + if (poco.IsSufficient) + { + await xmlWriter.WriteAttributeStringAsync(null, "isSufficient", null, "true"); + } + + if (!poco.IsUnique) + { + await xmlWriter.WriteAttributeStringAsync(null, "isUnique", null, "false"); + } + + if (poco.IsVariation) + { + await xmlWriter.WriteAttributeStringAsync(null, "isVariation", null, "true"); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.mayTimeVary) + { + await xmlWriter.WriteAttributeStringAsync(null, "mayTimeVary", null, "true"); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.multiplicity != null && poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "multiplicity", null, poco.multiplicity.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.name)) + { + await xmlWriter.WriteAttributeStringAsync(null, "name", null, poco.name); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedConjugator != null && poco.ownedConjugator.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedConjugator", null, poco.ownedConjugator.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedCrossSubsetting != null && poco.ownedCrossSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedCrossSubsetting", null, poco.ownedCrossSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.ownedReferenceSubsetting != null && poco.ownedReferenceSubsetting.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "ownedReferenceSubsetting", null, poco.ownedReferenceSubsetting.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owner != null && poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owner", null, poco.owner.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningDefinition != null && poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningDefinition", null, poco.owningDefinition.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningNamespace != null && poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningNamespace", null, poco.owningNamespace.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningType != null && poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningType", null, poco.owningType.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.owningUsage != null && poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "owningUsage", null, poco.owningUsage.Id.ToString()); + } + } + + if (poco.PortionKind.HasValue) + { + await xmlWriter.WriteAttributeStringAsync(null, "portionKind", null, poco.PortionKind.Value.ToString().ToLower()); + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.qualifiedName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "qualifiedName", null, poco.qualifiedName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (!string.IsNullOrWhiteSpace(poco.shortName)) + { + await xmlWriter.WriteAttributeStringAsync(null, "shortName", null, poco.shortName); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.untilArgument != null && poco.untilArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "untilArgument", null, poco.untilArgument.Id.ToString()); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (writerOptions.WriteIdRefAsAttribute && poco.whileArgument != null && poco.whileArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await xmlWriter.WriteAttributeStringAsync(null, "whileArgument", null, poco.whileArgument.Id.ToString()); + } + } + + + // Reference/containment properties as child elements (sorted alphabetically) + if (writerOptions.IncludeDerivedProperties) + { + if (poco.actionDefinition != null) + { + foreach (var item in poco.actionDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "actionDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.bodyAction != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.bodyAction.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.bodyAction, "bodyAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.chainingFeature != null) + { + foreach (var item in poco.chainingFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "chainingFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.crossFeature != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.crossFeature.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.crossFeature, "crossFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.differencingType != null) + { + foreach (var item in poco.differencingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "differencingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.directedUsage != null) + { + foreach (var item in poco.directedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "directedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.documentation != null) + { + foreach (var item in poco.documentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "documentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endFeature != null) + { + foreach (var item in poco.endFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "endFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.endOwningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.endOwningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.endOwningType, "endOwningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.feature != null) + { + foreach (var item in poco.feature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "feature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureMembership != null) + { + foreach (var item in poco.featureMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featureMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featureTarget != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.featureTarget.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.featureTarget, "featureTarget", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.featuringType != null) + { + foreach (var item in poco.featuringType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "featuringType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.importedMembership != null) + { + foreach (var item in poco.importedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "importedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.individualDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.individualDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.individualDefinition, "individualDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedFeature != null) + { + foreach (var item in poco.inheritedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.inheritedMembership != null) + { + foreach (var item in poco.inheritedMembership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "inheritedMembership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.input != null) + { + foreach (var item in poco.input) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "input", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.intersectingType != null) + { + foreach (var item in poco.intersectingType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "intersectingType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.member != null) + { + foreach (var item in poco.member) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "member", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.membership != null) + { + foreach (var item in poco.membership) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "membership", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.multiplicity != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.multiplicity.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.multiplicity, "multiplicity", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAction != null) + { + foreach (var item in poco.nestedAction) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAction", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAllocation != null) + { + foreach (var item in poco.nestedAllocation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAllocation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAnalysisCase != null) + { + foreach (var item in poco.nestedAnalysisCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAnalysisCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedAttribute != null) + { + foreach (var item in poco.nestedAttribute) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedAttribute", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCalculation != null) + { + foreach (var item in poco.nestedCalculation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCalculation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedCase != null) + { + foreach (var item in poco.nestedCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConcern != null) + { + foreach (var item in poco.nestedConcern) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConcern", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConnection != null) + { + foreach (var item in poco.nestedConnection) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConnection", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedConstraint != null) + { + foreach (var item in poco.nestedConstraint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedConstraint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedEnumeration != null) + { + foreach (var item in poco.nestedEnumeration) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedEnumeration", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedFlow != null) + { + foreach (var item in poco.nestedFlow) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedFlow", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedInterface != null) + { + foreach (var item in poco.nestedInterface) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedInterface", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedItem != null) + { + foreach (var item in poco.nestedItem) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedItem", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedMetadata != null) + { + foreach (var item in poco.nestedMetadata) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedMetadata", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedOccurrence != null) + { + foreach (var item in poco.nestedOccurrence) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedOccurrence", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPart != null) + { + foreach (var item in poco.nestedPart) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPart", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedPort != null) + { + foreach (var item in poco.nestedPort) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedPort", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedReference != null) + { + foreach (var item in poco.nestedReference) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedReference", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRendering != null) + { + foreach (var item in poco.nestedRendering) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRendering", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedRequirement != null) + { + foreach (var item in poco.nestedRequirement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedRequirement", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedState != null) + { + foreach (var item in poco.nestedState) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedState", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedTransition != null) + { + foreach (var item in poco.nestedTransition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedTransition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUsage != null) + { + foreach (var item in poco.nestedUsage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedUseCase != null) + { + foreach (var item in poco.nestedUseCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedUseCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedVerificationCase != null) + { + foreach (var item in poco.nestedVerificationCase) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedVerificationCase", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedView != null) + { + foreach (var item in poco.nestedView) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedView", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.nestedViewpoint != null) + { + foreach (var item in poco.nestedViewpoint) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "nestedViewpoint", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.occurrenceDefinition != null) + { + foreach (var item in poco.occurrenceDefinition) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "occurrenceDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.output != null) + { + foreach (var item in poco.output) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "output", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedAnnotation != null) + { + foreach (var item in poco.ownedAnnotation) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedAnnotation", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedConjugator != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedConjugator, "ownedConjugator", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedCrossSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedCrossSubsetting, "ownedCrossSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDifferencing != null) + { + foreach (var item in poco.ownedDifferencing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDifferencing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedDisjoining != null) + { + foreach (var item in poco.ownedDisjoining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedDisjoining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedElement != null) + { + foreach (var item in poco.ownedElement) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedElement", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedEndFeature != null) + { + foreach (var item in poco.ownedEndFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedEndFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeature != null) + { + foreach (var item in poco.ownedFeature) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedFeature", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureChaining != null) + { + foreach (var item in poco.ownedFeatureChaining) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureChaining", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureInverting != null) + { + foreach (var item in poco.ownedFeatureInverting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureInverting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedFeatureMembership != null) + { + foreach (var item in poco.ownedFeatureMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedFeatureMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedImport != null) + { + foreach (var item in poco.ownedImport) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedImport", writerOptions, elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedIntersecting != null) + { + foreach (var item in poco.ownedIntersecting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedIntersecting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMember != null) + { + foreach (var item in poco.ownedMember) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "ownedMember", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedMembership != null) + { + foreach (var item in poco.ownedMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedRedefinition != null) + { + foreach (var item in poco.ownedRedefinition) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRedefinition", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedReferenceSubsetting != null) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, poco.ownedReferenceSubsetting, "ownedReferenceSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + + if (poco.OwnedRelationship != null) + { + foreach (var item in poco.OwnedRelationship) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedRelationship", writerOptions, elementOriginMap, currentFileUri, true); + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSpecialization != null) + { + foreach (var item in poco.ownedSpecialization) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSpecialization", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedSubsetting != null) + { + foreach (var item in poco.ownedSubsetting) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedSubsetting", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTypeFeaturing != null) + { + foreach (var item in poco.ownedTypeFeaturing) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTypeFeaturing", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedTyping != null) + { + foreach (var item in poco.ownedTyping) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedTyping", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.ownedUnioning != null) + { + foreach (var item in poco.ownedUnioning) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "ownedUnioning", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owner != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owner.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owner, "owner", elementOriginMap, currentFileUri, true); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningDefinition != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningDefinition.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningDefinition, "owningDefinition", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningNamespace != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningNamespace.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningNamespace, "owningNamespace", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningType != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningType.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningType, "owningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.owningUsage != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.owningUsage.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.owningUsage, "owningUsage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.parameter != null) + { + foreach (var item in poco.parameter) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "parameter", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.textualRepresentation != null) + { + foreach (var item in poco.textualRepresentation) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "textualRepresentation", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.unioningType != null) + { + foreach (var item in poco.unioningType) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "unioningType", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.untilArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.untilArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.untilArgument, "untilArgument", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.usage != null) + { + foreach (var item in poco.usage) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "usage", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variant != null) + { + foreach (var item in poco.variant) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, item, "variant", elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.variantMembership != null) + { + foreach (var item in poco.variantMembership) + { + await this.XmiDataWriterFacade.WriteContainedElementAsync(xmlWriter, item, "variantMembership", writerOptions, elementOriginMap, currentFileUri); + } + } + } + + if (writerOptions.IncludeDerivedProperties) + { + if (poco.whileArgument != null) + { + if (!writerOptions.WriteIdRefAsAttribute || !poco.whileArgument.QueryIsValidIdRef(elementOriginMap, currentFileUri)) + { + await this.XmiDataWriterFacade.WriteReferenceElementAsync(xmlWriter, poco.whileArgument, "whileArgument", elementOriginMap, currentFileUri); + } + } + } + + + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/XmiDataWriterFacade.cs b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/XmiDataWriterFacade.cs new file mode 100644 index 000000000..526e1d8a7 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/AutoGenWriters/XmiDataWriterFacade.cs @@ -0,0 +1,1776 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using SysML2.NET.Common; + using SysML2.NET.Core.POCO.Root.Elements; + + /// + /// The purpose of the is to dispatch writing of instances + /// to the appropriate per-type writer class + /// + public class XmiDataWriterFacade : IXmiDataWriterFacade + { + /// + /// A dictionary that contains actions that write based on a key that represents the POCO type name + /// + private readonly Dictionary> writerCache; + + /// + /// A dictionary that contains functions that asynchronously write based on a key that represents the POCO type name + /// + private readonly Dictionary> writerAsyncCache; + + /// + /// Initializes a new instance of the + /// + /// The used to set up logging + public XmiDataWriterFacade(ILoggerFactory loggerFactory) + { + var acceptActionUsageWriter = new AcceptActionUsageWriter(this, loggerFactory); + var actionDefinitionWriter = new ActionDefinitionWriter(this, loggerFactory); + var actionUsageWriter = new ActionUsageWriter(this, loggerFactory); + var actorMembershipWriter = new ActorMembershipWriter(this, loggerFactory); + var allocationDefinitionWriter = new AllocationDefinitionWriter(this, loggerFactory); + var allocationUsageWriter = new AllocationUsageWriter(this, loggerFactory); + var analysisCaseDefinitionWriter = new AnalysisCaseDefinitionWriter(this, loggerFactory); + var analysisCaseUsageWriter = new AnalysisCaseUsageWriter(this, loggerFactory); + var annotatingElementWriter = new AnnotatingElementWriter(this, loggerFactory); + var annotationWriter = new AnnotationWriter(this, loggerFactory); + var assertConstraintUsageWriter = new AssertConstraintUsageWriter(this, loggerFactory); + var assignmentActionUsageWriter = new AssignmentActionUsageWriter(this, loggerFactory); + var associationWriter = new AssociationWriter(this, loggerFactory); + var associationStructureWriter = new AssociationStructureWriter(this, loggerFactory); + var attributeDefinitionWriter = new AttributeDefinitionWriter(this, loggerFactory); + var attributeUsageWriter = new AttributeUsageWriter(this, loggerFactory); + var behaviorWriter = new BehaviorWriter(this, loggerFactory); + var bindingConnectorWriter = new BindingConnectorWriter(this, loggerFactory); + var bindingConnectorAsUsageWriter = new BindingConnectorAsUsageWriter(this, loggerFactory); + var booleanExpressionWriter = new BooleanExpressionWriter(this, loggerFactory); + var calculationDefinitionWriter = new CalculationDefinitionWriter(this, loggerFactory); + var calculationUsageWriter = new CalculationUsageWriter(this, loggerFactory); + var caseDefinitionWriter = new CaseDefinitionWriter(this, loggerFactory); + var caseUsageWriter = new CaseUsageWriter(this, loggerFactory); + var classWriter = new ClassWriter(this, loggerFactory); + var classifierWriter = new ClassifierWriter(this, loggerFactory); + var collectExpressionWriter = new CollectExpressionWriter(this, loggerFactory); + var commentWriter = new CommentWriter(this, loggerFactory); + var concernDefinitionWriter = new ConcernDefinitionWriter(this, loggerFactory); + var concernUsageWriter = new ConcernUsageWriter(this, loggerFactory); + var conjugatedPortDefinitionWriter = new ConjugatedPortDefinitionWriter(this, loggerFactory); + var conjugatedPortTypingWriter = new ConjugatedPortTypingWriter(this, loggerFactory); + var conjugationWriter = new ConjugationWriter(this, loggerFactory); + var connectionDefinitionWriter = new ConnectionDefinitionWriter(this, loggerFactory); + var connectionUsageWriter = new ConnectionUsageWriter(this, loggerFactory); + var connectorWriter = new ConnectorWriter(this, loggerFactory); + var constraintDefinitionWriter = new ConstraintDefinitionWriter(this, loggerFactory); + var constraintUsageWriter = new ConstraintUsageWriter(this, loggerFactory); + var constructorExpressionWriter = new ConstructorExpressionWriter(this, loggerFactory); + var crossSubsettingWriter = new CrossSubsettingWriter(this, loggerFactory); + var dataTypeWriter = new DataTypeWriter(this, loggerFactory); + var decisionNodeWriter = new DecisionNodeWriter(this, loggerFactory); + var definitionWriter = new DefinitionWriter(this, loggerFactory); + var dependencyWriter = new DependencyWriter(this, loggerFactory); + var differencingWriter = new DifferencingWriter(this, loggerFactory); + var disjoiningWriter = new DisjoiningWriter(this, loggerFactory); + var documentationWriter = new DocumentationWriter(this, loggerFactory); + var elementFilterMembershipWriter = new ElementFilterMembershipWriter(this, loggerFactory); + var endFeatureMembershipWriter = new EndFeatureMembershipWriter(this, loggerFactory); + var enumerationDefinitionWriter = new EnumerationDefinitionWriter(this, loggerFactory); + var enumerationUsageWriter = new EnumerationUsageWriter(this, loggerFactory); + var eventOccurrenceUsageWriter = new EventOccurrenceUsageWriter(this, loggerFactory); + var exhibitStateUsageWriter = new ExhibitStateUsageWriter(this, loggerFactory); + var expressionWriter = new ExpressionWriter(this, loggerFactory); + var featureWriter = new FeatureWriter(this, loggerFactory); + var featureChainExpressionWriter = new FeatureChainExpressionWriter(this, loggerFactory); + var featureChainingWriter = new FeatureChainingWriter(this, loggerFactory); + var featureInvertingWriter = new FeatureInvertingWriter(this, loggerFactory); + var featureMembershipWriter = new FeatureMembershipWriter(this, loggerFactory); + var featureReferenceExpressionWriter = new FeatureReferenceExpressionWriter(this, loggerFactory); + var featureTypingWriter = new FeatureTypingWriter(this, loggerFactory); + var featureValueWriter = new FeatureValueWriter(this, loggerFactory); + var flowWriter = new FlowWriter(this, loggerFactory); + var flowDefinitionWriter = new FlowDefinitionWriter(this, loggerFactory); + var flowEndWriter = new FlowEndWriter(this, loggerFactory); + var flowUsageWriter = new FlowUsageWriter(this, loggerFactory); + var forkNodeWriter = new ForkNodeWriter(this, loggerFactory); + var forLoopActionUsageWriter = new ForLoopActionUsageWriter(this, loggerFactory); + var framedConcernMembershipWriter = new FramedConcernMembershipWriter(this, loggerFactory); + var functionWriter = new FunctionWriter(this, loggerFactory); + var ifActionUsageWriter = new IfActionUsageWriter(this, loggerFactory); + var includeUseCaseUsageWriter = new IncludeUseCaseUsageWriter(this, loggerFactory); + var indexExpressionWriter = new IndexExpressionWriter(this, loggerFactory); + var interactionWriter = new InteractionWriter(this, loggerFactory); + var interfaceDefinitionWriter = new InterfaceDefinitionWriter(this, loggerFactory); + var interfaceUsageWriter = new InterfaceUsageWriter(this, loggerFactory); + var intersectingWriter = new IntersectingWriter(this, loggerFactory); + var invariantWriter = new InvariantWriter(this, loggerFactory); + var invocationExpressionWriter = new InvocationExpressionWriter(this, loggerFactory); + var itemDefinitionWriter = new ItemDefinitionWriter(this, loggerFactory); + var itemUsageWriter = new ItemUsageWriter(this, loggerFactory); + var joinNodeWriter = new JoinNodeWriter(this, loggerFactory); + var libraryPackageWriter = new LibraryPackageWriter(this, loggerFactory); + var literalBooleanWriter = new LiteralBooleanWriter(this, loggerFactory); + var literalExpressionWriter = new LiteralExpressionWriter(this, loggerFactory); + var literalInfinityWriter = new LiteralInfinityWriter(this, loggerFactory); + var literalIntegerWriter = new LiteralIntegerWriter(this, loggerFactory); + var literalRationalWriter = new LiteralRationalWriter(this, loggerFactory); + var literalStringWriter = new LiteralStringWriter(this, loggerFactory); + var membershipWriter = new MembershipWriter(this, loggerFactory); + var membershipExposeWriter = new MembershipExposeWriter(this, loggerFactory); + var membershipImportWriter = new MembershipImportWriter(this, loggerFactory); + var mergeNodeWriter = new MergeNodeWriter(this, loggerFactory); + var metaclassWriter = new MetaclassWriter(this, loggerFactory); + var metadataAccessExpressionWriter = new MetadataAccessExpressionWriter(this, loggerFactory); + var metadataDefinitionWriter = new MetadataDefinitionWriter(this, loggerFactory); + var metadataFeatureWriter = new MetadataFeatureWriter(this, loggerFactory); + var metadataUsageWriter = new MetadataUsageWriter(this, loggerFactory); + var multiplicityWriter = new MultiplicityWriter(this, loggerFactory); + var multiplicityRangeWriter = new MultiplicityRangeWriter(this, loggerFactory); + var namespaceWriter = new NamespaceWriter(this, loggerFactory); + var namespaceExposeWriter = new NamespaceExposeWriter(this, loggerFactory); + var namespaceImportWriter = new NamespaceImportWriter(this, loggerFactory); + var nullExpressionWriter = new NullExpressionWriter(this, loggerFactory); + var objectiveMembershipWriter = new ObjectiveMembershipWriter(this, loggerFactory); + var occurrenceDefinitionWriter = new OccurrenceDefinitionWriter(this, loggerFactory); + var occurrenceUsageWriter = new OccurrenceUsageWriter(this, loggerFactory); + var operatorExpressionWriter = new OperatorExpressionWriter(this, loggerFactory); + var owningMembershipWriter = new OwningMembershipWriter(this, loggerFactory); + var packageWriter = new PackageWriter(this, loggerFactory); + var parameterMembershipWriter = new ParameterMembershipWriter(this, loggerFactory); + var partDefinitionWriter = new PartDefinitionWriter(this, loggerFactory); + var partUsageWriter = new PartUsageWriter(this, loggerFactory); + var payloadFeatureWriter = new PayloadFeatureWriter(this, loggerFactory); + var performActionUsageWriter = new PerformActionUsageWriter(this, loggerFactory); + var portConjugationWriter = new PortConjugationWriter(this, loggerFactory); + var portDefinitionWriter = new PortDefinitionWriter(this, loggerFactory); + var portUsageWriter = new PortUsageWriter(this, loggerFactory); + var predicateWriter = new PredicateWriter(this, loggerFactory); + var redefinitionWriter = new RedefinitionWriter(this, loggerFactory); + var referenceSubsettingWriter = new ReferenceSubsettingWriter(this, loggerFactory); + var referenceUsageWriter = new ReferenceUsageWriter(this, loggerFactory); + var renderingDefinitionWriter = new RenderingDefinitionWriter(this, loggerFactory); + var renderingUsageWriter = new RenderingUsageWriter(this, loggerFactory); + var requirementConstraintMembershipWriter = new RequirementConstraintMembershipWriter(this, loggerFactory); + var requirementDefinitionWriter = new RequirementDefinitionWriter(this, loggerFactory); + var requirementUsageWriter = new RequirementUsageWriter(this, loggerFactory); + var requirementVerificationMembershipWriter = new RequirementVerificationMembershipWriter(this, loggerFactory); + var resultExpressionMembershipWriter = new ResultExpressionMembershipWriter(this, loggerFactory); + var returnParameterMembershipWriter = new ReturnParameterMembershipWriter(this, loggerFactory); + var satisfyRequirementUsageWriter = new SatisfyRequirementUsageWriter(this, loggerFactory); + var selectExpressionWriter = new SelectExpressionWriter(this, loggerFactory); + var sendActionUsageWriter = new SendActionUsageWriter(this, loggerFactory); + var specializationWriter = new SpecializationWriter(this, loggerFactory); + var stakeholderMembershipWriter = new StakeholderMembershipWriter(this, loggerFactory); + var stateDefinitionWriter = new StateDefinitionWriter(this, loggerFactory); + var stateSubactionMembershipWriter = new StateSubactionMembershipWriter(this, loggerFactory); + var stateUsageWriter = new StateUsageWriter(this, loggerFactory); + var stepWriter = new StepWriter(this, loggerFactory); + var structureWriter = new StructureWriter(this, loggerFactory); + var subclassificationWriter = new SubclassificationWriter(this, loggerFactory); + var subjectMembershipWriter = new SubjectMembershipWriter(this, loggerFactory); + var subsettingWriter = new SubsettingWriter(this, loggerFactory); + var successionWriter = new SuccessionWriter(this, loggerFactory); + var successionAsUsageWriter = new SuccessionAsUsageWriter(this, loggerFactory); + var successionFlowWriter = new SuccessionFlowWriter(this, loggerFactory); + var successionFlowUsageWriter = new SuccessionFlowUsageWriter(this, loggerFactory); + var terminateActionUsageWriter = new TerminateActionUsageWriter(this, loggerFactory); + var textualRepresentationWriter = new TextualRepresentationWriter(this, loggerFactory); + var transitionFeatureMembershipWriter = new TransitionFeatureMembershipWriter(this, loggerFactory); + var transitionUsageWriter = new TransitionUsageWriter(this, loggerFactory); + var triggerInvocationExpressionWriter = new TriggerInvocationExpressionWriter(this, loggerFactory); + var typeWriter = new TypeWriter(this, loggerFactory); + var typeFeaturingWriter = new TypeFeaturingWriter(this, loggerFactory); + var unioningWriter = new UnioningWriter(this, loggerFactory); + var usageWriter = new UsageWriter(this, loggerFactory); + var useCaseDefinitionWriter = new UseCaseDefinitionWriter(this, loggerFactory); + var useCaseUsageWriter = new UseCaseUsageWriter(this, loggerFactory); + var variantMembershipWriter = new VariantMembershipWriter(this, loggerFactory); + var verificationCaseDefinitionWriter = new VerificationCaseDefinitionWriter(this, loggerFactory); + var verificationCaseUsageWriter = new VerificationCaseUsageWriter(this, loggerFactory); + var viewDefinitionWriter = new ViewDefinitionWriter(this, loggerFactory); + var viewpointDefinitionWriter = new ViewpointDefinitionWriter(this, loggerFactory); + var viewpointUsageWriter = new ViewpointUsageWriter(this, loggerFactory); + var viewRenderingMembershipWriter = new ViewRenderingMembershipWriter(this, loggerFactory); + var viewUsageWriter = new ViewUsageWriter(this, loggerFactory); + var whileLoopActionUsageWriter = new WhileLoopActionUsageWriter(this, loggerFactory); + + this.writerCache = new Dictionary> + { + ["AcceptActionUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + acceptActionUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Actions.IAcceptActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ActionDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + actionDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Actions.IActionDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ActionUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + actionUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Actions.IActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ActorMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + actorMembershipWriter.Write(xmlWriter, (Core.POCO.Systems.Requirements.IActorMembership)data, elementName, writerOptions, originMap, uri); + }, + ["AllocationDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + allocationDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Allocations.IAllocationDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["AllocationUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + allocationUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Allocations.IAllocationUsage)data, elementName, writerOptions, originMap, uri); + }, + ["AnalysisCaseDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + analysisCaseDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.AnalysisCases.IAnalysisCaseDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["AnalysisCaseUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + analysisCaseUsageWriter.Write(xmlWriter, (Core.POCO.Systems.AnalysisCases.IAnalysisCaseUsage)data, elementName, writerOptions, originMap, uri); + }, + ["AnnotatingElement"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + annotatingElementWriter.Write(xmlWriter, (Core.POCO.Root.Annotations.IAnnotatingElement)data, elementName, writerOptions, originMap, uri); + }, + ["Annotation"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + annotationWriter.Write(xmlWriter, (Core.POCO.Root.Annotations.IAnnotation)data, elementName, writerOptions, originMap, uri); + }, + ["AssertConstraintUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + assertConstraintUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Constraints.IAssertConstraintUsage)data, elementName, writerOptions, originMap, uri); + }, + ["AssignmentActionUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + assignmentActionUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Actions.IAssignmentActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Association"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + associationWriter.Write(xmlWriter, (Core.POCO.Kernel.Associations.IAssociation)data, elementName, writerOptions, originMap, uri); + }, + ["AssociationStructure"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + associationStructureWriter.Write(xmlWriter, (Core.POCO.Kernel.Associations.IAssociationStructure)data, elementName, writerOptions, originMap, uri); + }, + ["AttributeDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + attributeDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Attributes.IAttributeDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["AttributeUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + attributeUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Attributes.IAttributeUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Behavior"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + behaviorWriter.Write(xmlWriter, (Core.POCO.Kernel.Behaviors.IBehavior)data, elementName, writerOptions, originMap, uri); + }, + ["BindingConnector"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + bindingConnectorWriter.Write(xmlWriter, (Core.POCO.Kernel.Connectors.IBindingConnector)data, elementName, writerOptions, originMap, uri); + }, + ["BindingConnectorAsUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + bindingConnectorAsUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Connections.IBindingConnectorAsUsage)data, elementName, writerOptions, originMap, uri); + }, + ["BooleanExpression"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + booleanExpressionWriter.Write(xmlWriter, (Core.POCO.Kernel.Functions.IBooleanExpression)data, elementName, writerOptions, originMap, uri); + }, + ["CalculationDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + calculationDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Calculations.ICalculationDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["CalculationUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + calculationUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Calculations.ICalculationUsage)data, elementName, writerOptions, originMap, uri); + }, + ["CaseDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + caseDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Cases.ICaseDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["CaseUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + caseUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Cases.ICaseUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Class"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + classWriter.Write(xmlWriter, (Core.POCO.Kernel.Classes.IClass)data, elementName, writerOptions, originMap, uri); + }, + ["Classifier"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + classifierWriter.Write(xmlWriter, (Core.POCO.Core.Classifiers.IClassifier)data, elementName, writerOptions, originMap, uri); + }, + ["CollectExpression"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + collectExpressionWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.ICollectExpression)data, elementName, writerOptions, originMap, uri); + }, + ["Comment"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + commentWriter.Write(xmlWriter, (Core.POCO.Root.Annotations.IComment)data, elementName, writerOptions, originMap, uri); + }, + ["ConcernDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + concernDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Requirements.IConcernDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ConcernUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + concernUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Requirements.IConcernUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ConjugatedPortDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + conjugatedPortDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Ports.IConjugatedPortDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ConjugatedPortTyping"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + conjugatedPortTypingWriter.Write(xmlWriter, (Core.POCO.Systems.Ports.IConjugatedPortTyping)data, elementName, writerOptions, originMap, uri); + }, + ["Conjugation"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + conjugationWriter.Write(xmlWriter, (Core.POCO.Core.Types.IConjugation)data, elementName, writerOptions, originMap, uri); + }, + ["ConnectionDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + connectionDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Connections.IConnectionDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ConnectionUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + connectionUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Connections.IConnectionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Connector"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + connectorWriter.Write(xmlWriter, (Core.POCO.Kernel.Connectors.IConnector)data, elementName, writerOptions, originMap, uri); + }, + ["ConstraintDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + constraintDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Constraints.IConstraintDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ConstraintUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + constraintUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Constraints.IConstraintUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ConstructorExpression"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + constructorExpressionWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.IConstructorExpression)data, elementName, writerOptions, originMap, uri); + }, + ["CrossSubsetting"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + crossSubsettingWriter.Write(xmlWriter, (Core.POCO.Core.Features.ICrossSubsetting)data, elementName, writerOptions, originMap, uri); + }, + ["DataType"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + dataTypeWriter.Write(xmlWriter, (Core.POCO.Kernel.DataTypes.IDataType)data, elementName, writerOptions, originMap, uri); + }, + ["DecisionNode"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + decisionNodeWriter.Write(xmlWriter, (Core.POCO.Systems.Actions.IDecisionNode)data, elementName, writerOptions, originMap, uri); + }, + ["Definition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + definitionWriter.Write(xmlWriter, (Core.POCO.Systems.DefinitionAndUsage.IDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["Dependency"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + dependencyWriter.Write(xmlWriter, (Core.POCO.Root.Dependencies.IDependency)data, elementName, writerOptions, originMap, uri); + }, + ["Differencing"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + differencingWriter.Write(xmlWriter, (Core.POCO.Core.Types.IDifferencing)data, elementName, writerOptions, originMap, uri); + }, + ["Disjoining"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + disjoiningWriter.Write(xmlWriter, (Core.POCO.Core.Types.IDisjoining)data, elementName, writerOptions, originMap, uri); + }, + ["Documentation"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + documentationWriter.Write(xmlWriter, (Core.POCO.Root.Annotations.IDocumentation)data, elementName, writerOptions, originMap, uri); + }, + ["ElementFilterMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + elementFilterMembershipWriter.Write(xmlWriter, (Core.POCO.Kernel.Packages.IElementFilterMembership)data, elementName, writerOptions, originMap, uri); + }, + ["EndFeatureMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + endFeatureMembershipWriter.Write(xmlWriter, (Core.POCO.Core.Features.IEndFeatureMembership)data, elementName, writerOptions, originMap, uri); + }, + ["EnumerationDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + enumerationDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Enumerations.IEnumerationDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["EnumerationUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + enumerationUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Enumerations.IEnumerationUsage)data, elementName, writerOptions, originMap, uri); + }, + ["EventOccurrenceUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + eventOccurrenceUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Occurrences.IEventOccurrenceUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ExhibitStateUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + exhibitStateUsageWriter.Write(xmlWriter, (Core.POCO.Systems.States.IExhibitStateUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Expression"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + expressionWriter.Write(xmlWriter, (Core.POCO.Kernel.Functions.IExpression)data, elementName, writerOptions, originMap, uri); + }, + ["Feature"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + featureWriter.Write(xmlWriter, (Core.POCO.Core.Features.IFeature)data, elementName, writerOptions, originMap, uri); + }, + ["FeatureChainExpression"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + featureChainExpressionWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.IFeatureChainExpression)data, elementName, writerOptions, originMap, uri); + }, + ["FeatureChaining"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + featureChainingWriter.Write(xmlWriter, (Core.POCO.Core.Features.IFeatureChaining)data, elementName, writerOptions, originMap, uri); + }, + ["FeatureInverting"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + featureInvertingWriter.Write(xmlWriter, (Core.POCO.Core.Features.IFeatureInverting)data, elementName, writerOptions, originMap, uri); + }, + ["FeatureMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + featureMembershipWriter.Write(xmlWriter, (Core.POCO.Core.Types.IFeatureMembership)data, elementName, writerOptions, originMap, uri); + }, + ["FeatureReferenceExpression"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + featureReferenceExpressionWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.IFeatureReferenceExpression)data, elementName, writerOptions, originMap, uri); + }, + ["FeatureTyping"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + featureTypingWriter.Write(xmlWriter, (Core.POCO.Core.Features.IFeatureTyping)data, elementName, writerOptions, originMap, uri); + }, + ["FeatureValue"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + featureValueWriter.Write(xmlWriter, (Core.POCO.Kernel.FeatureValues.IFeatureValue)data, elementName, writerOptions, originMap, uri); + }, + ["Flow"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + flowWriter.Write(xmlWriter, (Core.POCO.Kernel.Interactions.IFlow)data, elementName, writerOptions, originMap, uri); + }, + ["FlowDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + flowDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Flows.IFlowDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["FlowEnd"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + flowEndWriter.Write(xmlWriter, (Core.POCO.Kernel.Interactions.IFlowEnd)data, elementName, writerOptions, originMap, uri); + }, + ["FlowUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + flowUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Flows.IFlowUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ForkNode"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + forkNodeWriter.Write(xmlWriter, (Core.POCO.Systems.Actions.IForkNode)data, elementName, writerOptions, originMap, uri); + }, + ["ForLoopActionUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + forLoopActionUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Actions.IForLoopActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["FramedConcernMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + framedConcernMembershipWriter.Write(xmlWriter, (Core.POCO.Systems.Requirements.IFramedConcernMembership)data, elementName, writerOptions, originMap, uri); + }, + ["Function"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + functionWriter.Write(xmlWriter, (Core.POCO.Kernel.Functions.IFunction)data, elementName, writerOptions, originMap, uri); + }, + ["IfActionUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + ifActionUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Actions.IIfActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["IncludeUseCaseUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + includeUseCaseUsageWriter.Write(xmlWriter, (Core.POCO.Systems.UseCases.IIncludeUseCaseUsage)data, elementName, writerOptions, originMap, uri); + }, + ["IndexExpression"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + indexExpressionWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.IIndexExpression)data, elementName, writerOptions, originMap, uri); + }, + ["Interaction"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + interactionWriter.Write(xmlWriter, (Core.POCO.Kernel.Interactions.IInteraction)data, elementName, writerOptions, originMap, uri); + }, + ["InterfaceDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + interfaceDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Interfaces.IInterfaceDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["InterfaceUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + interfaceUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Interfaces.IInterfaceUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Intersecting"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + intersectingWriter.Write(xmlWriter, (Core.POCO.Core.Types.IIntersecting)data, elementName, writerOptions, originMap, uri); + }, + ["Invariant"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + invariantWriter.Write(xmlWriter, (Core.POCO.Kernel.Functions.IInvariant)data, elementName, writerOptions, originMap, uri); + }, + ["InvocationExpression"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + invocationExpressionWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.IInvocationExpression)data, elementName, writerOptions, originMap, uri); + }, + ["ItemDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + itemDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Items.IItemDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ItemUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + itemUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Items.IItemUsage)data, elementName, writerOptions, originMap, uri); + }, + ["JoinNode"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + joinNodeWriter.Write(xmlWriter, (Core.POCO.Systems.Actions.IJoinNode)data, elementName, writerOptions, originMap, uri); + }, + ["LibraryPackage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + libraryPackageWriter.Write(xmlWriter, (Core.POCO.Kernel.Packages.ILibraryPackage)data, elementName, writerOptions, originMap, uri); + }, + ["LiteralBoolean"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + literalBooleanWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.ILiteralBoolean)data, elementName, writerOptions, originMap, uri); + }, + ["LiteralExpression"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + literalExpressionWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.ILiteralExpression)data, elementName, writerOptions, originMap, uri); + }, + ["LiteralInfinity"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + literalInfinityWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.ILiteralInfinity)data, elementName, writerOptions, originMap, uri); + }, + ["LiteralInteger"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + literalIntegerWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.ILiteralInteger)data, elementName, writerOptions, originMap, uri); + }, + ["LiteralRational"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + literalRationalWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.ILiteralRational)data, elementName, writerOptions, originMap, uri); + }, + ["LiteralString"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + literalStringWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.ILiteralString)data, elementName, writerOptions, originMap, uri); + }, + ["Membership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + membershipWriter.Write(xmlWriter, (Core.POCO.Root.Namespaces.IMembership)data, elementName, writerOptions, originMap, uri); + }, + ["MembershipExpose"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + membershipExposeWriter.Write(xmlWriter, (Core.POCO.Systems.Views.IMembershipExpose)data, elementName, writerOptions, originMap, uri); + }, + ["MembershipImport"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + membershipImportWriter.Write(xmlWriter, (Core.POCO.Root.Namespaces.IMembershipImport)data, elementName, writerOptions, originMap, uri); + }, + ["MergeNode"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + mergeNodeWriter.Write(xmlWriter, (Core.POCO.Systems.Actions.IMergeNode)data, elementName, writerOptions, originMap, uri); + }, + ["Metaclass"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + metaclassWriter.Write(xmlWriter, (Core.POCO.Kernel.Metadata.IMetaclass)data, elementName, writerOptions, originMap, uri); + }, + ["MetadataAccessExpression"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + metadataAccessExpressionWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.IMetadataAccessExpression)data, elementName, writerOptions, originMap, uri); + }, + ["MetadataDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + metadataDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Metadata.IMetadataDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["MetadataFeature"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + metadataFeatureWriter.Write(xmlWriter, (Core.POCO.Kernel.Metadata.IMetadataFeature)data, elementName, writerOptions, originMap, uri); + }, + ["MetadataUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + metadataUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Metadata.IMetadataUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Multiplicity"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + multiplicityWriter.Write(xmlWriter, (Core.POCO.Core.Types.IMultiplicity)data, elementName, writerOptions, originMap, uri); + }, + ["MultiplicityRange"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + multiplicityRangeWriter.Write(xmlWriter, (Core.POCO.Kernel.Multiplicities.IMultiplicityRange)data, elementName, writerOptions, originMap, uri); + }, + ["Namespace"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + namespaceWriter.Write(xmlWriter, (Core.POCO.Root.Namespaces.INamespace)data, elementName, writerOptions, originMap, uri); + }, + ["NamespaceExpose"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + namespaceExposeWriter.Write(xmlWriter, (Core.POCO.Systems.Views.INamespaceExpose)data, elementName, writerOptions, originMap, uri); + }, + ["NamespaceImport"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + namespaceImportWriter.Write(xmlWriter, (Core.POCO.Root.Namespaces.INamespaceImport)data, elementName, writerOptions, originMap, uri); + }, + ["NullExpression"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + nullExpressionWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.INullExpression)data, elementName, writerOptions, originMap, uri); + }, + ["ObjectiveMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + objectiveMembershipWriter.Write(xmlWriter, (Core.POCO.Systems.Cases.IObjectiveMembership)data, elementName, writerOptions, originMap, uri); + }, + ["OccurrenceDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + occurrenceDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Occurrences.IOccurrenceDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["OccurrenceUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + occurrenceUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Occurrences.IOccurrenceUsage)data, elementName, writerOptions, originMap, uri); + }, + ["OperatorExpression"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + operatorExpressionWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.IOperatorExpression)data, elementName, writerOptions, originMap, uri); + }, + ["OwningMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + owningMembershipWriter.Write(xmlWriter, (Core.POCO.Root.Namespaces.IOwningMembership)data, elementName, writerOptions, originMap, uri); + }, + ["Package"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + packageWriter.Write(xmlWriter, (Core.POCO.Kernel.Packages.IPackage)data, elementName, writerOptions, originMap, uri); + }, + ["ParameterMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + parameterMembershipWriter.Write(xmlWriter, (Core.POCO.Kernel.Behaviors.IParameterMembership)data, elementName, writerOptions, originMap, uri); + }, + ["PartDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + partDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Parts.IPartDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["PartUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + partUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Parts.IPartUsage)data, elementName, writerOptions, originMap, uri); + }, + ["PayloadFeature"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + payloadFeatureWriter.Write(xmlWriter, (Core.POCO.Kernel.Interactions.IPayloadFeature)data, elementName, writerOptions, originMap, uri); + }, + ["PerformActionUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + performActionUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Actions.IPerformActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["PortConjugation"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + portConjugationWriter.Write(xmlWriter, (Core.POCO.Systems.Ports.IPortConjugation)data, elementName, writerOptions, originMap, uri); + }, + ["PortDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + portDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Ports.IPortDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["PortUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + portUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Ports.IPortUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Predicate"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + predicateWriter.Write(xmlWriter, (Core.POCO.Kernel.Functions.IPredicate)data, elementName, writerOptions, originMap, uri); + }, + ["Redefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + redefinitionWriter.Write(xmlWriter, (Core.POCO.Core.Features.IRedefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ReferenceSubsetting"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + referenceSubsettingWriter.Write(xmlWriter, (Core.POCO.Core.Features.IReferenceSubsetting)data, elementName, writerOptions, originMap, uri); + }, + ["ReferenceUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + referenceUsageWriter.Write(xmlWriter, (Core.POCO.Systems.DefinitionAndUsage.IReferenceUsage)data, elementName, writerOptions, originMap, uri); + }, + ["RenderingDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + renderingDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Views.IRenderingDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["RenderingUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + renderingUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Views.IRenderingUsage)data, elementName, writerOptions, originMap, uri); + }, + ["RequirementConstraintMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + requirementConstraintMembershipWriter.Write(xmlWriter, (Core.POCO.Systems.Requirements.IRequirementConstraintMembership)data, elementName, writerOptions, originMap, uri); + }, + ["RequirementDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + requirementDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Requirements.IRequirementDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["RequirementUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + requirementUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Requirements.IRequirementUsage)data, elementName, writerOptions, originMap, uri); + }, + ["RequirementVerificationMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + requirementVerificationMembershipWriter.Write(xmlWriter, (Core.POCO.Systems.VerificationCases.IRequirementVerificationMembership)data, elementName, writerOptions, originMap, uri); + }, + ["ResultExpressionMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + resultExpressionMembershipWriter.Write(xmlWriter, (Core.POCO.Kernel.Functions.IResultExpressionMembership)data, elementName, writerOptions, originMap, uri); + }, + ["ReturnParameterMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + returnParameterMembershipWriter.Write(xmlWriter, (Core.POCO.Kernel.Functions.IReturnParameterMembership)data, elementName, writerOptions, originMap, uri); + }, + ["SatisfyRequirementUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + satisfyRequirementUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Requirements.ISatisfyRequirementUsage)data, elementName, writerOptions, originMap, uri); + }, + ["SelectExpression"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + selectExpressionWriter.Write(xmlWriter, (Core.POCO.Kernel.Expressions.ISelectExpression)data, elementName, writerOptions, originMap, uri); + }, + ["SendActionUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + sendActionUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Actions.ISendActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Specialization"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + specializationWriter.Write(xmlWriter, (Core.POCO.Core.Types.ISpecialization)data, elementName, writerOptions, originMap, uri); + }, + ["StakeholderMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + stakeholderMembershipWriter.Write(xmlWriter, (Core.POCO.Systems.Requirements.IStakeholderMembership)data, elementName, writerOptions, originMap, uri); + }, + ["StateDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + stateDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.States.IStateDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["StateSubactionMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + stateSubactionMembershipWriter.Write(xmlWriter, (Core.POCO.Systems.States.IStateSubactionMembership)data, elementName, writerOptions, originMap, uri); + }, + ["StateUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + stateUsageWriter.Write(xmlWriter, (Core.POCO.Systems.States.IStateUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Step"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + stepWriter.Write(xmlWriter, (Core.POCO.Kernel.Behaviors.IStep)data, elementName, writerOptions, originMap, uri); + }, + ["Structure"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + structureWriter.Write(xmlWriter, (Core.POCO.Kernel.Structures.IStructure)data, elementName, writerOptions, originMap, uri); + }, + ["Subclassification"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + subclassificationWriter.Write(xmlWriter, (Core.POCO.Core.Classifiers.ISubclassification)data, elementName, writerOptions, originMap, uri); + }, + ["SubjectMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + subjectMembershipWriter.Write(xmlWriter, (Core.POCO.Systems.Requirements.ISubjectMembership)data, elementName, writerOptions, originMap, uri); + }, + ["Subsetting"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + subsettingWriter.Write(xmlWriter, (Core.POCO.Core.Features.ISubsetting)data, elementName, writerOptions, originMap, uri); + }, + ["Succession"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + successionWriter.Write(xmlWriter, (Core.POCO.Kernel.Connectors.ISuccession)data, elementName, writerOptions, originMap, uri); + }, + ["SuccessionAsUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + successionAsUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Connections.ISuccessionAsUsage)data, elementName, writerOptions, originMap, uri); + }, + ["SuccessionFlow"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + successionFlowWriter.Write(xmlWriter, (Core.POCO.Kernel.Interactions.ISuccessionFlow)data, elementName, writerOptions, originMap, uri); + }, + ["SuccessionFlowUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + successionFlowUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Flows.ISuccessionFlowUsage)data, elementName, writerOptions, originMap, uri); + }, + ["TerminateActionUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + terminateActionUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Actions.ITerminateActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["TextualRepresentation"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + textualRepresentationWriter.Write(xmlWriter, (Core.POCO.Root.Annotations.ITextualRepresentation)data, elementName, writerOptions, originMap, uri); + }, + ["TransitionFeatureMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + transitionFeatureMembershipWriter.Write(xmlWriter, (Core.POCO.Systems.States.ITransitionFeatureMembership)data, elementName, writerOptions, originMap, uri); + }, + ["TransitionUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + transitionUsageWriter.Write(xmlWriter, (Core.POCO.Systems.States.ITransitionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["TriggerInvocationExpression"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + triggerInvocationExpressionWriter.Write(xmlWriter, (Core.POCO.Systems.Actions.ITriggerInvocationExpression)data, elementName, writerOptions, originMap, uri); + }, + ["Type"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + typeWriter.Write(xmlWriter, (Core.POCO.Core.Types.IType)data, elementName, writerOptions, originMap, uri); + }, + ["TypeFeaturing"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + typeFeaturingWriter.Write(xmlWriter, (Core.POCO.Core.Features.ITypeFeaturing)data, elementName, writerOptions, originMap, uri); + }, + ["Unioning"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + unioningWriter.Write(xmlWriter, (Core.POCO.Core.Types.IUnioning)data, elementName, writerOptions, originMap, uri); + }, + ["Usage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + usageWriter.Write(xmlWriter, (Core.POCO.Systems.DefinitionAndUsage.IUsage)data, elementName, writerOptions, originMap, uri); + }, + ["UseCaseDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + useCaseDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.UseCases.IUseCaseDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["UseCaseUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + useCaseUsageWriter.Write(xmlWriter, (Core.POCO.Systems.UseCases.IUseCaseUsage)data, elementName, writerOptions, originMap, uri); + }, + ["VariantMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + variantMembershipWriter.Write(xmlWriter, (Core.POCO.Systems.DefinitionAndUsage.IVariantMembership)data, elementName, writerOptions, originMap, uri); + }, + ["VerificationCaseDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + verificationCaseDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.VerificationCases.IVerificationCaseDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["VerificationCaseUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + verificationCaseUsageWriter.Write(xmlWriter, (Core.POCO.Systems.VerificationCases.IVerificationCaseUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ViewDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + viewDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Views.IViewDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ViewpointDefinition"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + viewpointDefinitionWriter.Write(xmlWriter, (Core.POCO.Systems.Views.IViewpointDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ViewpointUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + viewpointUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Views.IViewpointUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ViewRenderingMembership"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + viewRenderingMembershipWriter.Write(xmlWriter, (Core.POCO.Systems.Views.IViewRenderingMembership)data, elementName, writerOptions, originMap, uri); + }, + ["ViewUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + viewUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Views.IViewUsage)data, elementName, writerOptions, originMap, uri); + }, + ["WhileLoopActionUsage"] = (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + whileLoopActionUsageWriter.Write(xmlWriter, (Core.POCO.Systems.Actions.IWhileLoopActionUsage)data, elementName, writerOptions, originMap, uri); + }, + }; + + this.writerAsyncCache = new Dictionary> + { + ["AcceptActionUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await acceptActionUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Actions.IAcceptActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ActionDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await actionDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Actions.IActionDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ActionUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await actionUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Actions.IActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ActorMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await actorMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Requirements.IActorMembership)data, elementName, writerOptions, originMap, uri); + }, + ["AllocationDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await allocationDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Allocations.IAllocationDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["AllocationUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await allocationUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Allocations.IAllocationUsage)data, elementName, writerOptions, originMap, uri); + }, + ["AnalysisCaseDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await analysisCaseDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.AnalysisCases.IAnalysisCaseDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["AnalysisCaseUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await analysisCaseUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.AnalysisCases.IAnalysisCaseUsage)data, elementName, writerOptions, originMap, uri); + }, + ["AnnotatingElement"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await annotatingElementWriter.WriteAsync(xmlWriter, (Core.POCO.Root.Annotations.IAnnotatingElement)data, elementName, writerOptions, originMap, uri); + }, + ["Annotation"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await annotationWriter.WriteAsync(xmlWriter, (Core.POCO.Root.Annotations.IAnnotation)data, elementName, writerOptions, originMap, uri); + }, + ["AssertConstraintUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await assertConstraintUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Constraints.IAssertConstraintUsage)data, elementName, writerOptions, originMap, uri); + }, + ["AssignmentActionUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await assignmentActionUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Actions.IAssignmentActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Association"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await associationWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Associations.IAssociation)data, elementName, writerOptions, originMap, uri); + }, + ["AssociationStructure"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await associationStructureWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Associations.IAssociationStructure)data, elementName, writerOptions, originMap, uri); + }, + ["AttributeDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await attributeDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Attributes.IAttributeDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["AttributeUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await attributeUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Attributes.IAttributeUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Behavior"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await behaviorWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Behaviors.IBehavior)data, elementName, writerOptions, originMap, uri); + }, + ["BindingConnector"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await bindingConnectorWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Connectors.IBindingConnector)data, elementName, writerOptions, originMap, uri); + }, + ["BindingConnectorAsUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await bindingConnectorAsUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Connections.IBindingConnectorAsUsage)data, elementName, writerOptions, originMap, uri); + }, + ["BooleanExpression"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await booleanExpressionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Functions.IBooleanExpression)data, elementName, writerOptions, originMap, uri); + }, + ["CalculationDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await calculationDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Calculations.ICalculationDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["CalculationUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await calculationUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Calculations.ICalculationUsage)data, elementName, writerOptions, originMap, uri); + }, + ["CaseDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await caseDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Cases.ICaseDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["CaseUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await caseUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Cases.ICaseUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Class"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await classWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Classes.IClass)data, elementName, writerOptions, originMap, uri); + }, + ["Classifier"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await classifierWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Classifiers.IClassifier)data, elementName, writerOptions, originMap, uri); + }, + ["CollectExpression"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await collectExpressionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.ICollectExpression)data, elementName, writerOptions, originMap, uri); + }, + ["Comment"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await commentWriter.WriteAsync(xmlWriter, (Core.POCO.Root.Annotations.IComment)data, elementName, writerOptions, originMap, uri); + }, + ["ConcernDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await concernDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Requirements.IConcernDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ConcernUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await concernUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Requirements.IConcernUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ConjugatedPortDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await conjugatedPortDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Ports.IConjugatedPortDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ConjugatedPortTyping"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await conjugatedPortTypingWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Ports.IConjugatedPortTyping)data, elementName, writerOptions, originMap, uri); + }, + ["Conjugation"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await conjugationWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Types.IConjugation)data, elementName, writerOptions, originMap, uri); + }, + ["ConnectionDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await connectionDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Connections.IConnectionDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ConnectionUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await connectionUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Connections.IConnectionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Connector"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await connectorWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Connectors.IConnector)data, elementName, writerOptions, originMap, uri); + }, + ["ConstraintDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await constraintDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Constraints.IConstraintDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ConstraintUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await constraintUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Constraints.IConstraintUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ConstructorExpression"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await constructorExpressionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.IConstructorExpression)data, elementName, writerOptions, originMap, uri); + }, + ["CrossSubsetting"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await crossSubsettingWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Features.ICrossSubsetting)data, elementName, writerOptions, originMap, uri); + }, + ["DataType"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await dataTypeWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.DataTypes.IDataType)data, elementName, writerOptions, originMap, uri); + }, + ["DecisionNode"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await decisionNodeWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Actions.IDecisionNode)data, elementName, writerOptions, originMap, uri); + }, + ["Definition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await definitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.DefinitionAndUsage.IDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["Dependency"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await dependencyWriter.WriteAsync(xmlWriter, (Core.POCO.Root.Dependencies.IDependency)data, elementName, writerOptions, originMap, uri); + }, + ["Differencing"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await differencingWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Types.IDifferencing)data, elementName, writerOptions, originMap, uri); + }, + ["Disjoining"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await disjoiningWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Types.IDisjoining)data, elementName, writerOptions, originMap, uri); + }, + ["Documentation"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await documentationWriter.WriteAsync(xmlWriter, (Core.POCO.Root.Annotations.IDocumentation)data, elementName, writerOptions, originMap, uri); + }, + ["ElementFilterMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await elementFilterMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Packages.IElementFilterMembership)data, elementName, writerOptions, originMap, uri); + }, + ["EndFeatureMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await endFeatureMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Features.IEndFeatureMembership)data, elementName, writerOptions, originMap, uri); + }, + ["EnumerationDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await enumerationDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Enumerations.IEnumerationDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["EnumerationUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await enumerationUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Enumerations.IEnumerationUsage)data, elementName, writerOptions, originMap, uri); + }, + ["EventOccurrenceUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await eventOccurrenceUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Occurrences.IEventOccurrenceUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ExhibitStateUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await exhibitStateUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.States.IExhibitStateUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Expression"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await expressionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Functions.IExpression)data, elementName, writerOptions, originMap, uri); + }, + ["Feature"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await featureWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Features.IFeature)data, elementName, writerOptions, originMap, uri); + }, + ["FeatureChainExpression"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await featureChainExpressionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.IFeatureChainExpression)data, elementName, writerOptions, originMap, uri); + }, + ["FeatureChaining"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await featureChainingWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Features.IFeatureChaining)data, elementName, writerOptions, originMap, uri); + }, + ["FeatureInverting"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await featureInvertingWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Features.IFeatureInverting)data, elementName, writerOptions, originMap, uri); + }, + ["FeatureMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await featureMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Types.IFeatureMembership)data, elementName, writerOptions, originMap, uri); + }, + ["FeatureReferenceExpression"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await featureReferenceExpressionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.IFeatureReferenceExpression)data, elementName, writerOptions, originMap, uri); + }, + ["FeatureTyping"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await featureTypingWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Features.IFeatureTyping)data, elementName, writerOptions, originMap, uri); + }, + ["FeatureValue"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await featureValueWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.FeatureValues.IFeatureValue)data, elementName, writerOptions, originMap, uri); + }, + ["Flow"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await flowWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Interactions.IFlow)data, elementName, writerOptions, originMap, uri); + }, + ["FlowDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await flowDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Flows.IFlowDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["FlowEnd"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await flowEndWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Interactions.IFlowEnd)data, elementName, writerOptions, originMap, uri); + }, + ["FlowUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await flowUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Flows.IFlowUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ForkNode"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await forkNodeWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Actions.IForkNode)data, elementName, writerOptions, originMap, uri); + }, + ["ForLoopActionUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await forLoopActionUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Actions.IForLoopActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["FramedConcernMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await framedConcernMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Requirements.IFramedConcernMembership)data, elementName, writerOptions, originMap, uri); + }, + ["Function"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await functionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Functions.IFunction)data, elementName, writerOptions, originMap, uri); + }, + ["IfActionUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await ifActionUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Actions.IIfActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["IncludeUseCaseUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await includeUseCaseUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.UseCases.IIncludeUseCaseUsage)data, elementName, writerOptions, originMap, uri); + }, + ["IndexExpression"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await indexExpressionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.IIndexExpression)data, elementName, writerOptions, originMap, uri); + }, + ["Interaction"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await interactionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Interactions.IInteraction)data, elementName, writerOptions, originMap, uri); + }, + ["InterfaceDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await interfaceDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Interfaces.IInterfaceDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["InterfaceUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await interfaceUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Interfaces.IInterfaceUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Intersecting"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await intersectingWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Types.IIntersecting)data, elementName, writerOptions, originMap, uri); + }, + ["Invariant"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await invariantWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Functions.IInvariant)data, elementName, writerOptions, originMap, uri); + }, + ["InvocationExpression"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await invocationExpressionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.IInvocationExpression)data, elementName, writerOptions, originMap, uri); + }, + ["ItemDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await itemDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Items.IItemDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ItemUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await itemUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Items.IItemUsage)data, elementName, writerOptions, originMap, uri); + }, + ["JoinNode"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await joinNodeWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Actions.IJoinNode)data, elementName, writerOptions, originMap, uri); + }, + ["LibraryPackage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await libraryPackageWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Packages.ILibraryPackage)data, elementName, writerOptions, originMap, uri); + }, + ["LiteralBoolean"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await literalBooleanWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.ILiteralBoolean)data, elementName, writerOptions, originMap, uri); + }, + ["LiteralExpression"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await literalExpressionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.ILiteralExpression)data, elementName, writerOptions, originMap, uri); + }, + ["LiteralInfinity"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await literalInfinityWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.ILiteralInfinity)data, elementName, writerOptions, originMap, uri); + }, + ["LiteralInteger"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await literalIntegerWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.ILiteralInteger)data, elementName, writerOptions, originMap, uri); + }, + ["LiteralRational"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await literalRationalWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.ILiteralRational)data, elementName, writerOptions, originMap, uri); + }, + ["LiteralString"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await literalStringWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.ILiteralString)data, elementName, writerOptions, originMap, uri); + }, + ["Membership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await membershipWriter.WriteAsync(xmlWriter, (Core.POCO.Root.Namespaces.IMembership)data, elementName, writerOptions, originMap, uri); + }, + ["MembershipExpose"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await membershipExposeWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Views.IMembershipExpose)data, elementName, writerOptions, originMap, uri); + }, + ["MembershipImport"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await membershipImportWriter.WriteAsync(xmlWriter, (Core.POCO.Root.Namespaces.IMembershipImport)data, elementName, writerOptions, originMap, uri); + }, + ["MergeNode"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await mergeNodeWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Actions.IMergeNode)data, elementName, writerOptions, originMap, uri); + }, + ["Metaclass"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await metaclassWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Metadata.IMetaclass)data, elementName, writerOptions, originMap, uri); + }, + ["MetadataAccessExpression"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await metadataAccessExpressionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.IMetadataAccessExpression)data, elementName, writerOptions, originMap, uri); + }, + ["MetadataDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await metadataDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Metadata.IMetadataDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["MetadataFeature"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await metadataFeatureWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Metadata.IMetadataFeature)data, elementName, writerOptions, originMap, uri); + }, + ["MetadataUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await metadataUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Metadata.IMetadataUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Multiplicity"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await multiplicityWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Types.IMultiplicity)data, elementName, writerOptions, originMap, uri); + }, + ["MultiplicityRange"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await multiplicityRangeWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Multiplicities.IMultiplicityRange)data, elementName, writerOptions, originMap, uri); + }, + ["Namespace"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await namespaceWriter.WriteAsync(xmlWriter, (Core.POCO.Root.Namespaces.INamespace)data, elementName, writerOptions, originMap, uri); + }, + ["NamespaceExpose"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await namespaceExposeWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Views.INamespaceExpose)data, elementName, writerOptions, originMap, uri); + }, + ["NamespaceImport"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await namespaceImportWriter.WriteAsync(xmlWriter, (Core.POCO.Root.Namespaces.INamespaceImport)data, elementName, writerOptions, originMap, uri); + }, + ["NullExpression"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await nullExpressionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.INullExpression)data, elementName, writerOptions, originMap, uri); + }, + ["ObjectiveMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await objectiveMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Cases.IObjectiveMembership)data, elementName, writerOptions, originMap, uri); + }, + ["OccurrenceDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await occurrenceDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Occurrences.IOccurrenceDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["OccurrenceUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await occurrenceUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Occurrences.IOccurrenceUsage)data, elementName, writerOptions, originMap, uri); + }, + ["OperatorExpression"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await operatorExpressionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.IOperatorExpression)data, elementName, writerOptions, originMap, uri); + }, + ["OwningMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await owningMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Root.Namespaces.IOwningMembership)data, elementName, writerOptions, originMap, uri); + }, + ["Package"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await packageWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Packages.IPackage)data, elementName, writerOptions, originMap, uri); + }, + ["ParameterMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await parameterMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Behaviors.IParameterMembership)data, elementName, writerOptions, originMap, uri); + }, + ["PartDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await partDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Parts.IPartDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["PartUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await partUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Parts.IPartUsage)data, elementName, writerOptions, originMap, uri); + }, + ["PayloadFeature"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await payloadFeatureWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Interactions.IPayloadFeature)data, elementName, writerOptions, originMap, uri); + }, + ["PerformActionUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await performActionUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Actions.IPerformActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["PortConjugation"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await portConjugationWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Ports.IPortConjugation)data, elementName, writerOptions, originMap, uri); + }, + ["PortDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await portDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Ports.IPortDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["PortUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await portUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Ports.IPortUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Predicate"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await predicateWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Functions.IPredicate)data, elementName, writerOptions, originMap, uri); + }, + ["Redefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await redefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Features.IRedefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ReferenceSubsetting"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await referenceSubsettingWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Features.IReferenceSubsetting)data, elementName, writerOptions, originMap, uri); + }, + ["ReferenceUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await referenceUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.DefinitionAndUsage.IReferenceUsage)data, elementName, writerOptions, originMap, uri); + }, + ["RenderingDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await renderingDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Views.IRenderingDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["RenderingUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await renderingUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Views.IRenderingUsage)data, elementName, writerOptions, originMap, uri); + }, + ["RequirementConstraintMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await requirementConstraintMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Requirements.IRequirementConstraintMembership)data, elementName, writerOptions, originMap, uri); + }, + ["RequirementDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await requirementDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Requirements.IRequirementDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["RequirementUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await requirementUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Requirements.IRequirementUsage)data, elementName, writerOptions, originMap, uri); + }, + ["RequirementVerificationMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await requirementVerificationMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.VerificationCases.IRequirementVerificationMembership)data, elementName, writerOptions, originMap, uri); + }, + ["ResultExpressionMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await resultExpressionMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Functions.IResultExpressionMembership)data, elementName, writerOptions, originMap, uri); + }, + ["ReturnParameterMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await returnParameterMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Functions.IReturnParameterMembership)data, elementName, writerOptions, originMap, uri); + }, + ["SatisfyRequirementUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await satisfyRequirementUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Requirements.ISatisfyRequirementUsage)data, elementName, writerOptions, originMap, uri); + }, + ["SelectExpression"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await selectExpressionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Expressions.ISelectExpression)data, elementName, writerOptions, originMap, uri); + }, + ["SendActionUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await sendActionUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Actions.ISendActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Specialization"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await specializationWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Types.ISpecialization)data, elementName, writerOptions, originMap, uri); + }, + ["StakeholderMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await stakeholderMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Requirements.IStakeholderMembership)data, elementName, writerOptions, originMap, uri); + }, + ["StateDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await stateDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.States.IStateDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["StateSubactionMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await stateSubactionMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.States.IStateSubactionMembership)data, elementName, writerOptions, originMap, uri); + }, + ["StateUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await stateUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.States.IStateUsage)data, elementName, writerOptions, originMap, uri); + }, + ["Step"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await stepWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Behaviors.IStep)data, elementName, writerOptions, originMap, uri); + }, + ["Structure"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await structureWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Structures.IStructure)data, elementName, writerOptions, originMap, uri); + }, + ["Subclassification"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await subclassificationWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Classifiers.ISubclassification)data, elementName, writerOptions, originMap, uri); + }, + ["SubjectMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await subjectMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Requirements.ISubjectMembership)data, elementName, writerOptions, originMap, uri); + }, + ["Subsetting"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await subsettingWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Features.ISubsetting)data, elementName, writerOptions, originMap, uri); + }, + ["Succession"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await successionWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Connectors.ISuccession)data, elementName, writerOptions, originMap, uri); + }, + ["SuccessionAsUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await successionAsUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Connections.ISuccessionAsUsage)data, elementName, writerOptions, originMap, uri); + }, + ["SuccessionFlow"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await successionFlowWriter.WriteAsync(xmlWriter, (Core.POCO.Kernel.Interactions.ISuccessionFlow)data, elementName, writerOptions, originMap, uri); + }, + ["SuccessionFlowUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await successionFlowUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Flows.ISuccessionFlowUsage)data, elementName, writerOptions, originMap, uri); + }, + ["TerminateActionUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await terminateActionUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Actions.ITerminateActionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["TextualRepresentation"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await textualRepresentationWriter.WriteAsync(xmlWriter, (Core.POCO.Root.Annotations.ITextualRepresentation)data, elementName, writerOptions, originMap, uri); + }, + ["TransitionFeatureMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await transitionFeatureMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.States.ITransitionFeatureMembership)data, elementName, writerOptions, originMap, uri); + }, + ["TransitionUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await transitionUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.States.ITransitionUsage)data, elementName, writerOptions, originMap, uri); + }, + ["TriggerInvocationExpression"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await triggerInvocationExpressionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Actions.ITriggerInvocationExpression)data, elementName, writerOptions, originMap, uri); + }, + ["Type"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await typeWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Types.IType)data, elementName, writerOptions, originMap, uri); + }, + ["TypeFeaturing"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await typeFeaturingWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Features.ITypeFeaturing)data, elementName, writerOptions, originMap, uri); + }, + ["Unioning"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await unioningWriter.WriteAsync(xmlWriter, (Core.POCO.Core.Types.IUnioning)data, elementName, writerOptions, originMap, uri); + }, + ["Usage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await usageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.DefinitionAndUsage.IUsage)data, elementName, writerOptions, originMap, uri); + }, + ["UseCaseDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await useCaseDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.UseCases.IUseCaseDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["UseCaseUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await useCaseUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.UseCases.IUseCaseUsage)data, elementName, writerOptions, originMap, uri); + }, + ["VariantMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await variantMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.DefinitionAndUsage.IVariantMembership)data, elementName, writerOptions, originMap, uri); + }, + ["VerificationCaseDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await verificationCaseDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.VerificationCases.IVerificationCaseDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["VerificationCaseUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await verificationCaseUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.VerificationCases.IVerificationCaseUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ViewDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await viewDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Views.IViewDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ViewpointDefinition"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await viewpointDefinitionWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Views.IViewpointDefinition)data, elementName, writerOptions, originMap, uri); + }, + ["ViewpointUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await viewpointUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Views.IViewpointUsage)data, elementName, writerOptions, originMap, uri); + }, + ["ViewRenderingMembership"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await viewRenderingMembershipWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Views.IViewRenderingMembership)data, elementName, writerOptions, originMap, uri); + }, + ["ViewUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await viewUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Views.IViewUsage)data, elementName, writerOptions, originMap, uri); + }, + ["WhileLoopActionUsage"] = async (xmlWriter, data, elementName, writerOptions, originMap, uri) => + { + await whileLoopActionUsageWriter.WriteAsync(xmlWriter, (Core.POCO.Systems.Actions.IWhileLoopActionUsage)data, elementName, writerOptions, originMap, uri); + }, + }; + } + + /// + /// Writes the specified as an XMI element by dispatching to the appropriate per-type writer + /// + /// The target + /// The to write + /// The XML element name to use + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The of the current output file for relative href computation + public void Write(XmlWriter xmlWriter, IData data, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + var typeName = data.GetType().Name; + + if (this.writerCache.TryGetValue(typeName, out var writer)) + { + writer(xmlWriter, data, elementName, writerOptions, elementOriginMap, currentFileUri); + } + else + { + throw new InvalidOperationException($"No writer found for type {typeName}"); + } + } + + /// + /// Writes a contained child element, checking origin map for cross-file href + /// + /// The target + /// The child to write + /// The XML element name to use + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The of the current output file for relative href computation + /// Asserts that the XSI type should be specified in case of HREF + public void WriteContainedElement(XmlWriter xmlWriter, IData childData, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, bool shouldSpecifyType = false) + { + if (!writerOptions.IncludeImplied && childData is IRelationship rel && rel.IsImplied) + { + return; + } + + if (elementOriginMap != null && currentFileUri != null) + { + var childSourceFile = elementOriginMap.GetSourceFile(childData.Id); + + if (childSourceFile != null && childSourceFile != currentFileUri) + { + WriteHrefElement(xmlWriter, childData, elementName, childSourceFile, currentFileUri, shouldSpecifyType); + return; + } + } + + this.Write(xmlWriter, childData, elementName, writerOptions, elementOriginMap, currentFileUri); + } + + /// + /// Writes a reference child element, checking origin map for cross-file href + /// + /// The target + /// The child to write + /// The XML element name to use + /// The optional for href reconstruction + /// The of the current output file for relative href computation + /// Asserts that the XSI type should be specified in case of HREF + public void WriteReferenceElement(XmlWriter xmlWriter, IData childData, string elementName, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, bool shouldSpecifyType = false) + { + if (elementOriginMap != null && currentFileUri != null) + { + var childSourceFile = elementOriginMap.GetSourceFile(childData.Id); + + if (childSourceFile != null && childSourceFile != currentFileUri) + { + WriteHrefElement(xmlWriter, childData, elementName, childSourceFile, currentFileUri, shouldSpecifyType); + return; + } + } + + xmlWriter.WriteStartElement(elementName); + xmlWriter.WriteAttributeString("xmi", "idref", null, childData.Id.ToString()); + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes the specified as an XMI element by dispatching to the appropriate per-type writer + /// + /// The target + /// The to write + /// The XML element name to use + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The of the current output file for relative href computation + public async Task WriteAsync(XmlWriter xmlWriter, IData data, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null) + { + var typeName = data.GetType().Name; + + if (this.writerAsyncCache.TryGetValue(typeName, out var writer)) + { + await writer(xmlWriter, data, elementName, writerOptions, elementOriginMap, currentFileUri); + } + else + { + throw new InvalidOperationException($"No writer found for type {typeName}"); + } + } + + /// + /// Asynchronously writes a contained child element, checking origin map for cross-file href + /// + /// The target + /// The child to write + /// The XML element name to use + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The of the current output file for relative href computation + /// Asserts that the XSI type should be specified in case of HREF + public async Task WriteContainedElementAsync(XmlWriter xmlWriter, IData childData, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, bool shouldSpecifyType = false) + { + if (!writerOptions.IncludeImplied && childData is IRelationship rel && rel.IsImplied) + { + return; + } + + if (elementOriginMap != null && currentFileUri != null) + { + var childSourceFile = elementOriginMap.GetSourceFile(childData.Id); + + if (childSourceFile != null && childSourceFile != currentFileUri) + { + await WriteHrefElementAsync(xmlWriter, childData, elementName, childSourceFile, currentFileUri, shouldSpecifyType); + return; + } + } + + await this.WriteAsync(xmlWriter, childData, elementName, writerOptions, elementOriginMap, currentFileUri); + } + + /// + /// Asynchronously writes a reference child element, checking origin map for cross-file href + /// + /// The target + /// The child to write + /// The XML element name to use + /// The optional for href reconstruction + /// The of the current output file for relative href computation + /// Asserts that the XSI type should be specified in case of HREF + public async Task WriteReferenceElementAsync(XmlWriter xmlWriter, IData childData, string elementName, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, bool shouldSpecifyType = false) + { + if (elementOriginMap != null && currentFileUri != null) + { + var childSourceFile = elementOriginMap.GetSourceFile(childData.Id); + + if (childSourceFile != null && childSourceFile != currentFileUri) + { + await WriteHrefElementAsync(xmlWriter, childData, elementName, childSourceFile, currentFileUri, shouldSpecifyType); + return; + } + } + + await xmlWriter.WriteStartElementAsync(null, elementName, null); + await xmlWriter.WriteAttributeStringAsync("xmi", "idref", null, childData.Id.ToString()); + await xmlWriter.WriteEndElementAsync(); + } + + /// + /// Writes an href element for cross-file references + /// + private static void WriteHrefElement(XmlWriter xmlWriter, IData childData, string elementName, Uri targetFile, Uri currentFile, bool shouldSpecifyType) + { + var relativePath = currentFile.MakeRelativeUri(targetFile); + var href = $"{Uri.UnescapeDataString(relativePath.ToString())}#{childData.Id}"; + + xmlWriter.WriteStartElement(elementName); + + if (shouldSpecifyType) + { + xmlWriter.WriteAttributeString("xsi", "type", null, $"sysml:{childData.GetType().Name}"); + } + + xmlWriter.WriteAttributeString("href", href); + xmlWriter.WriteEndElement(); + } + + /// + /// Asynchronously writes an href element for cross-file references + /// + private static async Task WriteHrefElementAsync(XmlWriter xmlWriter, IData childData, string elementName, Uri targetFile, Uri currentFile, bool shouldSpecifyType) + { + var relativePath = currentFile.MakeRelativeUri(targetFile); + var href = $"{Uri.UnescapeDataString(relativePath.ToString())}#{childData.Id}"; + + await xmlWriter.WriteStartElementAsync(null, elementName, null); + + if (shouldSpecifyType) + { + await xmlWriter.WriteAttributeStringAsync("xsi", "type", null, $"sysml:{childData.GetType().Name}"); + } + + await xmlWriter.WriteAttributeStringAsync(null, "href", null, href); + await xmlWriter.WriteEndElementAsync(); + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/SysML2.NET.Serializer.Xmi/Writers/IXmiDataWriterFacade.cs b/SysML2.NET.Serializer.Xmi/Writers/IXmiDataWriterFacade.cs new file mode 100644 index 000000000..8ba7c0672 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/IXmiDataWriterFacade.cs @@ -0,0 +1,103 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Threading.Tasks; + using System.Xml; + + using SysML2.NET.Common; + + /// + /// The purpose of the is to dispatch writing of instances + /// to the appropriate per-type static writer class + /// + public interface IXmiDataWriterFacade + { + /// + /// Writes the specified as an XMI element by dispatching to the appropriate per-type writer + /// + /// The target + /// The to write + /// The XML element name to use + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The of the current output file for relative href computation + void Write(XmlWriter xmlWriter, IData data, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null); + + /// + /// Writes a contained child element, checking origin map for cross-file href + /// + /// The target + /// The child to write + /// The XML element name to use + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The of the current output file for relative href computation + /// Asserts that the XSI type should be specified in case of HREF + void WriteContainedElement(XmlWriter xmlWriter, IData childData, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, bool shouldSpecifyType = false); + + /// + /// Writes a reference child element, checking origin map for cross-file href + /// + /// The target + /// The child to write + /// The XML element name to use + /// The optional for href reconstruction + /// The of the current output file for relative href computation + /// Asserts that the XSI type should be specified in case of HREF + void WriteReferenceElement(XmlWriter xmlWriter, IData childData, string elementName, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, bool shouldSpecifyType = false); + + /// + /// Asynchronously writes the specified as an XMI element by dispatching to the appropriate per-type writer + /// + /// The target + /// The to write + /// The XML element name to use + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The of the current output file for relative href computation + Task WriteAsync(XmlWriter xmlWriter, IData data, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, Uri currentFileUri = null); + + /// + /// Asynchronously writes a contained child element, checking origin map for cross-file href + /// + /// The target + /// The child to write + /// The XML element name to use + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The of the current output file for relative href computation + /// Asserts that the XSI type should be specified in case of HREF + Task WriteContainedElementAsync(XmlWriter xmlWriter, IData childData, string elementName, XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, bool shouldSpecifyType = false); + + /// + /// Asynchronously writes a reference child element, checking origin map for cross-file href + /// + /// The target + /// The child to write + /// The XML element name to use + /// The optional for href reconstruction + /// The of the current output file for relative href computation + /// Asserts that the XSI type should be specified in case of HREF + Task WriteReferenceElementAsync(XmlWriter xmlWriter, IData childData, string elementName, IXmiElementOriginMap elementOriginMap, Uri currentFileUri, bool shouldSpecifyType = false); + } +} diff --git a/SysML2.NET.Serializer.Xmi/Writers/XmiDataWriter.cs b/SysML2.NET.Serializer.Xmi/Writers/XmiDataWriter.cs new file mode 100644 index 000000000..95ed58a52 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/XmiDataWriter.cs @@ -0,0 +1,87 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + using System; + using System.Threading.Tasks; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using SysML2.NET.Common; + + /// + /// Abstract super class for each XMI writer + /// + /// The type of that needs to be written + public abstract class XmiDataWriter where TData : IData + { + /// + /// The injected that provides dispatch to per-type writers + /// + protected readonly IXmiDataWriterFacade XmiDataWriterFacade; + + /// + /// The injected used to set up logging + /// + protected readonly ILoggerFactory LoggerFactory; + + /// + /// Initializes a new instance of the + /// + /// + /// The injected that provides dispatch to per-type writers + /// + /// The injected used to set up logging + protected XmiDataWriter(IXmiDataWriterFacade xmiDataWriterFacade, ILoggerFactory loggerFactory) + { + this.XmiDataWriterFacade = xmiDataWriterFacade; + this.LoggerFactory = loggerFactory; + } + + /// + /// Writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + public abstract void Write(XmlWriter xmlWriter, TData data, string elementName, + XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, + Uri currentFileUri = null); + + /// + /// Asynchronously writes the object to its XML representation + /// + /// The target + /// The to write + /// The XML element name + /// The instance that provides writer output configuration + /// The optional for href reconstruction + /// The optional of the current output file + /// An awaitable + public abstract Task WriteAsync(XmlWriter xmlWriter, TData data, string elementName, + XmiWriterOptions writerOptions, IXmiElementOriginMap elementOriginMap = null, + Uri currentFileUri = null); + } +} diff --git a/SysML2.NET.Serializer.Xmi/Writers/XmiWriterOptions.cs b/SysML2.NET.Serializer.Xmi/Writers/XmiWriterOptions.cs new file mode 100644 index 000000000..4c7ccd00e --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/Writers/XmiWriterOptions.cs @@ -0,0 +1,49 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi.Writers +{ + /// + /// The provides centralized option provided to to customize output format + /// + public class XmiWriterOptions + { + /// + /// Asserts if derived properties have to be included or not. + /// + public bool IncludeDerivedProperties { get; set; } + + /// + /// Asserts if implied properties have to be included or not. + /// The project-level includesImplied flag as defined in KerML Clause 10, Note 5. + /// When true, all implied relationships are serialized and every element's isImpliedIncluded + /// attribute is written as "true". When false, implied relationships (where + /// is true) are excluded + /// and no element's isImpliedIncluded attribute is written. + /// + public bool IncludeImplied { get; set; } + + /// + /// Asserts if Id Reference values have to be written as attribute, when applicable. + /// Default value is true + /// + public bool WriteIdRefAsAttribute { get; set; } = true; + } +} diff --git a/SysML2.NET.Serializer.Xmi/XmiElementOriginMap.cs b/SysML2.NET.Serializer.Xmi/XmiElementOriginMap.cs new file mode 100644 index 000000000..aa4105de9 --- /dev/null +++ b/SysML2.NET.Serializer.Xmi/XmiElementOriginMap.cs @@ -0,0 +1,101 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2022-2026 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace SysML2.NET.Serializer.Xmi +{ + using System; + using System.Collections.Generic; + using System.Linq; + + /// + /// Tracks the association between elements and the XMI source files they were deserialized from. + /// + public class XmiElementOriginMap : IXmiElementOriginMap + { + /// + /// Maps element identifiers to their source file URIs + /// + private readonly Dictionary elementToFile = new Dictionary(); + + /// + /// Maps source file URIs to their root namespace identifiers + /// + private readonly Dictionary fileToRootNamespace = new Dictionary(); + + /// + /// Registers the source file for a given element + /// + /// The identifier of the element + /// The of the source XMI file + public void Register(Guid elementId, Uri sourceFile) + { + this.elementToFile[elementId] = sourceFile; + } + + /// + /// Gets the source file for a given element + /// + /// The identifier of the element + /// The of the source file, or null if not tracked + public Uri GetSourceFile(Guid elementId) + { + return this.elementToFile.TryGetValue(elementId, out var sourceFile) ? sourceFile : null; + } + + /// + /// Gets all element identifiers that were deserialized from the given source file + /// + /// The of the source XMI file + /// An of element identifiers + public IEnumerable GetElementsInFile(Uri sourceFile) + { + return this.elementToFile.Where(kvp => kvp.Value == sourceFile).Select(kvp => kvp.Key); + } + + /// + /// Gets all source files that have been registered + /// + /// An of source file URIs + public IEnumerable GetAllSourceFiles() + { + return this.elementToFile.Values.Distinct(); + } + + /// + /// Registers the root namespace identifier for a given source file + /// + /// The of the source XMI file + /// The of the root namespace element + public void RegisterRootNamespace(Uri sourceFile, Guid rootNamespaceId) + { + this.fileToRootNamespace[sourceFile] = rootNamespaceId; + } + + /// + /// Gets the root namespace identifier for a given source file + /// + /// The of the source XMI file + /// The of the root namespace, or if not registered + public Guid GetRootNamespaceId(Uri sourceFile) + { + return this.fileToRootNamespace.TryGetValue(sourceFile, out var rootNamespaceId) ? rootNamespaceId : Guid.Empty; + } + } +}